This is what I'm trying to do: Write a program that prompts the user to enter an integer for today’s day of the week (Sunday is 0, Monday is 1, ..., and Saturday is 6). Also prompt the user to enter the number of days after today for a future day and dis- play the future day of the week.
Can anyone tell me how there is an error in my prompts? I got the program running perfectly on my computer but when I submit it to the online grader system, it tells me that only the first line of output is working.
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
}
}