Concept explainers
Implementation of a program with a given set of requirements
Program Plan:
Write a C++ program with a main function and the required set of statements to accomplish the following:
Write C++ statements that include the header files iostream and string
Write a C++ statement that allows you to use cin, cout, and endl without the prefix std::.
Write C++ statements that declare and initialize the following named constants: SECRET of type int initialized to 11 and RATE of type double initialized to 12.50
Write C++ statements that declare the following variables: num1, num2, and newNum of type int; name of type string; and hoursWorked and wages of type double
Write C++ statements that prompt the user to input two integers and store the first number in num1 and the second number in num2
Write a C++ statement(s) that outputs the values of num1 and num2, indicating which is num1 and which is num2. For example, if num1 is 8 and num2 is 5, then the output is,
The value of num1 = 8 and the value of num2 = 5.
Write a C++ statement that multiplies the value of num1 by 2, adds the value of num2 to it, and then stores the result in newNum. Then, write a C++ statement that outputs the value of newNum
Write a C++ statement that updates the value of newNum by adding the value of the named constant SECRET to it. Then, write a C++ statement that outputs the value of newNum with an appropriate message
Write C++ statements that prompt the user to enter a person’s last name and then store the last name into the variable name
Write C++ statements that prompt the user to enter a decimal number between 0 and 70 and then store the number entered into hoursWorked
Write a C++ statement that multiplies the value of the named constant RATE with the value of hoursWorked and then stores the result into the variable wages
Write C++ statements that produce output similar to:
Name: Rainbow
Pay Rate: $12.50
Hours Worked: 45.50
Salary: $568.75
Write a C++ program that tests each of the C++ statements that you wrote in parts A through L. Place the statements at the appropriate place in the C++ program segment given at the beginning of this problem. Test run your program (twice) on the following input data:
num1 = 13, num2 = 28; name = "Jacobson"; hoursWorked = 48.30.
num1 = 32, num2 = 15; name = "Crawford"; hoursWorked = 58.45.
Trending nowThis is a popular solution!
Chapter 2 Solutions
C++ PROGRAMMING LMS MINDTAP
- C++arrow_forwardin c++ add the request for the month number and read it in, add the request for the year and read it in, Ask what format the user would like to see the date in and write the if statement that will use the value in (format variable) to print out the date in the correct format. */ #include <iostream> using namespace std; int main() { short day, month, year, format; // Request day of the month (as a number) and put in day variable cout << "Enter a day of the month (1, 12, 30, etc): "; cin >> day; cout << "Formats are (1) YYYY/MM/DD, (2) DD/MM/YYYY, and (3) MM/DD/YYYY" << endl; cout << "Enter the number for the format you want (1, 2, or 3): "; cin >> format; }arrow_forwardC++ programmingarrow_forward
- C++arrow_forwardin c++ Write a program to generate a random number between 1 - 100, and then display which quartile the number falls in. First quartile is 1 - 25 Second quartile is 26 - 50 Third quartile is 51 - 75 Fourth quartile is 76 - 100 To generate a random number, follow these steps: include necessary header files #include <cstdlib> //for random functions #include <ctime> //for time functions set constants for the minimum and maximum values of the desired range const int MIN_VALUE = 1; //minimum range value const int MAX_VALUE = 100; //maximum range value seed the random number generator (RNG) with a unique unsigned int value - system time! unsigned seed = time(0); //system time in seconds since 1/1/1970 srand(seed); //seed the RNG get a random number in the desired range int num = (rand() % (MAX_VALUE - MIN_VALUE + 1)) + MIN_VALUE; The program should: contain header comments as shown in class display a "hello" message (more descriptive than shown in sample)…arrow_forwardFor C++ Code Template: //Include statements#include <iostream>#include <string> using namespace std; //Global declarations: Constants and type definitions only -- no variables //Function prototypes int main(){ //In cout statement below substitute your name cout << "Your name" << endl << endl; //Variable declarations //Program logic //Closing program statements system("pause"); return 0;} //Function definitionsarrow_forward
- 1. The C++ statement num = 1; compares the contents of the num variable to the number 1. Group of answer choices True False 2. The user can interactively terminate a program loop through the use of a Group of answer choices semicolon scope resolution operator sentinel value kryptonite 3. A do-while statement Group of answer choices automatically performs a validity check on data will always execute at least on time None may never executearrow_forwardC++arrow_forwardC++arrow_forward
- Computer graphicsarrow_forward4. A user enters an email address in a string variable in C++. Write a program that displays whether the email address contains any digit or not.arrow_forwardExercise 5: Please perform in C++ Write a program that lets the user perform arithmetic operations on two numbers. Your program must be menu driven, allowing the user to select the operation (+,-, *, or /) and input the numbers. ● ● ● Furthermore, your program must consist of the following functions: Function showChoice(): This function shows the options to the user and explains how to enter data. Function add(): This function accepts two numbers as arguments and returns the O O O O Function subtract(): This function accepts two numbers as arguments and returns their difference. O Function multiply(): This function accepts two numbers as arguments and returns the product. Function divide(): This function accepts two numbers as arguments and returns the quotient. sum.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