Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Activitiesfusionswitch {
- public static void main(String[] args) {
- /* Combining All Activities using Switch method
- * RnB Dela Pe�a
- */
- Scanner rnb = new Scanner(System.in);
- System.out.print("Choose Number 1-8 for Activities: ");
- int activity=rnb.nextInt();
- switch (activity) {
- case 1: System.out.println("\nYou Choose Activity 1 ADD or EVEN Number ");
- System.out.print("\nPlease Enter Number: ");
- int ae=rnb.nextInt();
- if (ae%2 == 0) {
- System.out.print(ae+ " is an even number");
- }
- else
- {
- System.out.print("This is an ODD number");
- }
- break;
- case 2: System.out.print("You Choose Activity 5 Colors Using Switch");
- System.out.print("Choose a letter from R O Y G B I V or r o y g b i v:: ");
- String InputColor = rnb.next();
- switch (InputColor){
- case "R": case "r":
- System.out.print("The color you have selected is Red");
- break;
- case "O": case "o":
- System.out.print("The color you have selected is Orange");
- break;
- case "Y": case "y":
- System.out.print("The color you have selected is Yellow");
- break;
- case "G": case "g":
- System.out.print("The color you have selected is Green");
- break;
- case "B": case "b":
- System.out.print("The color you have selected is Blue");
- break;
- case "I": case "i":
- System.out.print("The color you have selected is Indigo");
- break;
- case "V": case "v":
- System.out.print("The color you have selected is Violet");
- break;
- case 6:/* */
- int Val0 = rnb.nextInt();
- System.out.print("Please enter 2nd value: ");
- int Val1 = rnb.nextInt();
- System.out.print("Please enter 3rd value: ");
- int Val2 = rnb.nextInt();
- if ((Val0 >= Val2) && (Val1>=Val2))
- {
- System.out.print (Val0+ " is the largest among all values");
- }
- else if ((Val1>=Val0)&&(Val1>=Val2))
- {
- System.out.print(Val1+" is the largest among all values");
- }
- else if ((Val2>=Val0)&&(Val2>=Val1))
- {
- System.out.print(Val2+" is the largest among all values");
- }
- case 7:
- long val1 = rnb.nextLong();
- int digits = 1;
- if (val1 >=10 && val1<=10)
- {
- digits = 2;
- if (val1>=100 && val1<=100)
- {
- digits = 3;
- }
- else if (val1 >=1000 && val1 <=1000)
- {
- digits = 4;
- }
- System.out.print(val1+ " is a "+digits+" digit number");
- }
- case 8:
- int val1 = rnb.nextInt();
- System.out.print("Please enter the OPERATOR to be use: ");
- char operators = rnb.next().charAt(0);
- System.out.print("Please enter the 2nd value: ");
- int val2 = rnb.nextInt();
- int total = 0;
- switch(operators )
- {
- case '*':
- total = val1 * val2;
- System.out.print(val1+" "+operators+" "+val2+" = "+total);
- break;
- case '/':
- total = val1 / val2;
- System.out.print(val1+" "+operators+" "+val2+" = "+total);
- break;
- case '+':
- total = val1 + val2;
- System.out.print(val1+" "+operators+" "+val2+" = "+total);
- break;
- case '-':
- total = val1 - val2;
- System.out.print(val1+" "+operators+" "+val2+" = "+total);
- break;
- case '%':
- total = val1 % val2;
- System.out.print(val1+" "+operators+" "+val2+" = "+total);
- break;
- default:
- System.out.print("The number you entered is out of the list");
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement