import java.util.Scanner; public class Dayafter100 { public static void main(String[] args) { //3. Write a program that will find the day after 100 days from today. // Hint: count from 1 starting from Monday, use modulo operator int dayNow = 27; //int daysAfter = 100; Scanner scanner = new Scanner(System.in); System.out.println("Please Enter daysAfter: "); int daysAfter = scanner.nextInt(); int dayAfter100 = (daysAfter + dayNow)%7; if (dayAfter100 == 1) { System.out.println("The day in 100 will be Monday. "); } if (dayAfter100 == 2) { System.out.println("The day in 100 will be Tuesday. "); } if (dayAfter100 == 3) { System.out.println("The day in 100 will be Wendsday. "); } if (dayAfter100 == 4) { System.out.println("The day in 100 will be Thursday. "); } if (dayAfter100 == 5) { System.out.println("The day in 100 will be Friday. "); } if (dayAfter100 == 6) { System.out.println("The day in 100 will be Saturday. "); } if (dayAfter100 == 7) { System.out.println("The day in 100 will be Sunday. "); } } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter