Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** A simple script inspired from this C++ example : https://www.macs.hw.ac.uk/~pjbk/pathways/cpp1/node105.html
- *
- * INPUT: Integer (1 to 7), with 1 being "Sunday".
- * OUTPUT: Day of the week, if successful, "Not an allowable day number" if not.
- **/
- import java.util.*;
- public class Day {
- public static void main(String[] args) {
- System.out.println("Input a number from 1-7 of the day of the week.");
- Scanner scan = new Scanner(System.in);
- int day = scan.nextInt();
- switch (day)
- {
- case 1 : System.out.println("Sunday");
- break;
- case 2 : System.out.println("Monday");
- break;
- case 3 : System.out.println("Tuesday");
- break;
- case 4 : System.out.println("Wednesday");
- break;
- case 5 : System.out.println("Thursday");
- break;
- case 6 : System.out.println("Friday");
- break;
- case 7 : System.out.println("Saturday");
- break;
- default : System.out.println("Not an allowable day number");
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement