Java - 提示中的错误

时间:2017-06-30 23:58:59

标签: java output

这就是我要做的事情:编写一个程序,提示用户输入当前星期几的整数(星期日为0,星期一为1,...,星期六为6) )。同时提示用户输入今天之后的未来天数,并显示一周中的未来日期

有人能告诉我提示中的错误吗?我让程序在我的计算机上运行得很好但是当我将它提交到在线分级系统时,它告诉我只有第一行输出正在工作。

import java.util.Scanner; //import scanner

public class FindFutureDates{
public static void main(String[] args){

    Scanner input = new Scanner(System.in); //create a scanner object

    System.out.print("Enter today's day:"); //ask user for integer

    int dayIntInput = input.nextInt(); //assign next integer input to dayInt

    String[] daysOfWeek = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; //make array of days of week

    String firstDayOfWeek = daysOfWeek[dayIntInput]; //create string that holds value of first input converted to the name of the day

    System.out.print("Enter the number of days elapsed since today:"); //ask user to input another number

    int numberOfDaysInFuture = input.nextInt(); //create new variable based off user input 

    int firstDayPlusDaysInFuture = numberOfDaysInFuture + dayIntInput; //total number of days 
    String finalDay = daysOfWeek[firstDayPlusDaysInFuture%7];

    System.out.print("Today is " + firstDayOfWeek + " and the future day is " + finalDay); //final output with both days included

    }
}  

0 个答案:

没有答案