0% found this document useful (0 votes)
16 views1 page

FT-PT2 CP

The document is a Java program that prompts the user to enter a number between 1 and 7, which corresponds to the days of the week. It uses a switch statement to print the name of the day based on the user's input. If the input is not within the specified range, it outputs an 'Invalid Number Input' message.

Uploaded by

trialmailbynix
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views1 page

FT-PT2 CP

The document is a Java program that prompts the user to enter a number between 1 and 7, which corresponds to the days of the week. It uses a switch statement to print the name of the day based on the user's input. If the input is not within the specified range, it outputs an 'Invalid Number Input' message.

Uploaded by

trialmailbynix
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

YMANA, MICO A.

TVL – ICT : ALONZO


FT-PT #2

import java.util.Scanner; // in this line, here we imported the java utility which is the
scanner. // as usual, we use the java main method.

class Main { public static void


main(String[] args) {
Scanner myObj = new Scanner(System.in);

// in this line, we defined the variable.


int day;

/*This is where we put the scanner using "myObj" with


the print line that contains the requested input*/
System.out.println("Enter Number 1-7:"); day =
myObj.nextInt();

switch (day) {
case 1:
System.out.println("Monday.");
break;
case 2:
System.out.println("Tuesday.");
break; case 3:
System.out.println("Wednesday."); break; case 4:
System.out.println("Thursday"); break;
case 5:
System.out.println("Friday"); break;
case 6:
System.out.println("Saturday"); break;
case 7:
System.out.println("Sunday"); Break;
default:
System.out.println("Invalid Number Input"); break;
}
}
}

You might also like