0

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

    }
}  
David
  • 97
  • 6
  • If you don't enter the numbers on separate lines, or you're piping input from stdin, the "Enter" messages appear on the same line, e.g. http://ideone.com/8nY5f2. Perhaps it wants them on separate lines? – Andy Turner Jul 01 '17 at 00:02
  • ive tried your suggestion and now the grader is showing zero output. its unreliable software this grading machine.... i sent in a formal error notice to the people who made it. – David Jul 01 '17 at 00:05
  • 1
    @David, this question looks almost the same as yours, maybe it can help https://stackoverflow.com/questions/12993698/java-find-the-future-date-with-if-else-statements, as well as https://github.com/mlnorman/Intro-To-Java-Programming/blob/master/Chp3/Exercise_03_05.java – chickity china chinese chicken Jul 01 '17 at 00:27

0 Answers0