Concept explainers
How would I write this
Purpose:
The main purpose of the program is that if we are entering a number then as each number will have a month the number corresponding month has to be shown and the code is as shown below
Code:
class Main {
public static void main(String argu[]) {
//we are considering the month is 1
int m = 1;
//here is the switch condition
switch (m) {
case 1:
System.out.println("Month is January");// January will be printed
break;
case 2:
System.out.println("Month is February");// February will be printed
break;
case 3:
System.out.println("Month is March");// March will be printed
break;
case 4:
System.out.println("Month is April");// April will be printed
break;
case 5:
System.out.println("Month is May");// May will be printed
break;
case 6:
System.out.println("Month is June");// June will be printed
break;
case 7:
System.out.println("Month is July");// July will be printed
break;
case 8:
System.out.println("Month is August");// August will be printed
break;
case 9:
System.out.println("Month is September");// September will be printed
break;
case 10:
System.out.println("Month is October");// October will be printed
break;
case 11:
System.out.println("Month is November");// November will be printed
break;
case 12:
System.out.println("Month is December");// December will be printed
break;
default:
System.out.println("Invalid input - Wrong month number.");
break;
}
}
}
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images
- QUESTION 5 Which statement type is a loop control structure that includes a loop-control variable, a test, and an update in its statement header? a. do O b. for Oc. do...while d. casearrow_forwardIt is a C++ programming topic. Show the screenshot of the program.arrow_forwardQUESTION 18 If the break statement is omitted, then after executing the code for one case, the computer will go on to execute which case? Next case Last case default First casearrow_forward
- Write a C program that asks a student to enter his/her scores in Test 1, Test 2, and Test 3, and then it using a switch statement prints a grade of A, B, C, D, or F based on the maximum score earned on either of the three tests.arrow_forwardDon't give me AI generated answer or plagiarised answer. If I see these things I'll give you multiple downvotes and will report immediately.arrow_forwardCould this please be written in C++ 11, Thanks ! Write a program that calculates how much a person earns in a month if the salary is one penny on the first day, two pennies on the second day, four pennies on the third day, and so on with the daily pay doubling each day the employee works. The program should ask the user for the number of days the employee worked during the month, validate that it is between 1 and 31, and then display a table showing how much the salary was for each day worked, as well as the total pay earned for the month. The output should be displayed in dollars with two decimal points, not in pennies.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education