Concept explainers
Complete the following
#include <iostream>
using namespace std;
int main()
{
int userNum;
cout << "Enter one of the numbers 1, 2, or 3: ”;
cin >> userNum;
//
// Write the switch statement here.
//
return 0;
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
EBK STARTING OUT WITH C++
Additional Engineering Textbook Solutions
Problem Solving with C++ (9th Edition)
Starting Out with C++: Early Objects
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Starting Out with Programming Logic and Design (4th Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
Concepts of Programming Languages (11th Edition)
- conditional structures Create a program that will ask for the username and password.USER NAME:PASSWORD:Note:a. Correct username and password combination, display “You entered a valid username and password combination” and “Access Granted”.b. Incorrect username and/or password combination, display “Please check your input”, “Username and/or the password is invalid”, and “Access Denied”.arrow_forwardRemaining Time: 54 minutes, 49 seconds. * Question Completion Status: QUESTION 19 Write a Java program that prompts the user to enter the School Grade Level of a student and then calculate their discount amount in the regular fees structure offered during this pandemic situation. By using the below table, calculate their discount amount from the amount of the regular fee and then print the discount amount in OMR by using the appropriate selection structure. (Assume the user is entering a maximum Grade level is 12) discount amount = Regular Fees * percentage of discount rate School Grade Level Regular Fees in OMR Discount Rate >9 and 6 and 3 and 0 and <=3 30.500 5% otherwise 20.400 No discount T T T Arial 3 (12pt) v T -E E- 只i ン Click Save and Submit to save and submit. Click Save All Answers to save all answers. Save All Answers TOSHIBA F5 F6 F7 F8 F9 F10 F11 F12 INS SCNULL LOCK AD & 67 7 V 8A9 4 0arrow_forwardC++ Programming Instructions Write a program that prompts the user for a sequence of characters (all typed on a single line) and counts the number of vowels ('a', 'e', 'i', 'o', 'u'), consonants, and any other characters that appear in the input. The user terminates input by typing either the period (.) or exclamation mark character (!) followed by the Enter key on your keyboard. Your program will not count white space characters.I.e., you will ignore white space characters.Though, the cin statement will skip white space characters in the input for you. Your program will not be case-sensitive. Thus, the characters 'a' and 'A' are both vowels and the characters 'b' and 'B' are both consonants. For example, the input How? 1, 2, 3. contains one vowel, two consonants, and six other kinds of characters. IMPORTANT: Your program must use the while statement only when looping. I.e., do not use a for statement or any other looping statement. Test 1 > run Enter text: . Your sentence has 0…arrow_forward
- Time CalculatorWrite a program that asks the user to enter a number of seconds.-There are 60 seconds in a minute. If the number of seconds entered by the user is greater than or equal to 60, the program should display the number of minutes and leftover seconds in that many seconds.-There are 3,600 seconds in an hour. If the number of seconds entered by the user is greater than or equal to 3,600, the program should display the number of hours, minutes, and leftover seconds in that many seconds.-There are 86,400 seconds in a day. If the number of seconds entered by the user is greater than or equal to 86,400, the program should display the number of days, hours, minutes, and leftover seconds in that many seconds.arrow_forwardIV. PROCEDURES / RESULTS / SKILLS TESTING Skills Testing 1 (Students should work on their own)-Refer to Example 2. Page 3 Task 1: Write a program that will add the marks of a student in Theory and in practical of C Programming and test whether the mark is passed or failed. If the total mark is >= 75, the message displayed should be "You passed the course!". Otherwise, the message should be "You failed the coursel" Screen view result: Enter the Theory mark of the student in C programming (0-70) Enter the Practical mark of the student in C programming (0-30) 50 25 The total mark is 75 and you passed the course! ONLINE COMPILERarrow_forwardC++ Visual 2019 Create a change-counting game that gets the user to enter the number of coins required to make exactly one dollar.The program should ask the user to enter the number of pennies, nickels, dimes, and quarters. If the total value of the coins entered is equal to one dollar, the program should congratulate the user for winning the game. Otherwise, the program should display a message indicating whether the amount entered was more than or less than one dollar.arrow_forward
- c++ The code segment will display Hello: int a = 1; switch (a){ case a: cout<<"Hello"; break; default: cout<<"Hello"; } Select one: True Falsearrow_forward3- Enter a=3; b-5; c=7, then clear the variable b onlyarrow_forwardComputer Fundamentals and Programming 2 Write a program that determines a student’s grade. The program will accept 3 scores and computes the average score. Determine the grade based on the following rules: - If the average score is equal or greater than 90, the grade is A. - If the average score is greater than or equal to 70 and less than 90, the grade is B. - If the average score is greater than or equal to 50 and less than 70, the grade is C. - If the average score is less than 50, the grade is F. Source Codes and Print Screen of the Outputarrow_forward
- C++ coding help Write a program that prompts the user for a positive integer, the first term in a hailstone sequence, and then generates a subsequence from that hailstone number to the next occurrence of 1 in the sequence. The program should also determine and display the sum and length of the subsequence. If the user enters an integer less than 1, the program should display an error message as shown in the sample run. In order for the program to handle large integers, use long rather than int when declaring them.arrow_forwardChapter 5 Selection Statement ASSIGNMENT3 1. Using the switch statement, write a program that converts a numerical grade into a letter grade: Enter numerical grade: 84 Letter grade: B Use the following grading scale: A = 90~100, B = 80~89, C = 70~79, D = 60~69, F = 0~59. Print an error message if the grade is larger than 100 or less than 0. Hint: Break the grade into two digits, then use a switch statement to test the ten’s digit. 1. Write your program here: #include <stdio.h> int main(){ …… return 0; } 2. Write a program that asks the user for a two-digit number, then prints the English word for the number: Enter a two-digit number: 45 You entered the number forty-five. Hint: Break the number into two digits. Use one switch statement to print the word for the First digit (“twenty” “thirty" and so forth). Use a second switch statement to print the word for the second digit. Don’t forget that the numbers between 11 and 19 require special treatment. 2. Write your…arrow_forwardA mail-order house sells five products whose retail prices are as follows: Product 1, $2.98; product 2, $4.50; prod- uct 3, $9.98; product 4, $4.49 and product 5, $6.87. Write an application that reads a series of pairs of numbers as follows: a) product number b) quantity sold Your program should use a switch statement to determine the retail price for each product. It should calculate and display the total retail value of all products sold. Use a sentinel-controlled loop to determine when the pro- gram should stop looping and display the final results.arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning