-
-
Save dmarquand/84122537bec467bb8148f9eee9c099d7 to your computer and use it in GitHub Desktop.
firstProgram
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.println("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.println("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.println("Today is " + firstDayOfWeek + " and the future day is " + finalDay + "."); //final output with both days included | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment