Concept explainers
Using your text editor, enter (that is, type in) the C++
Creation of main method to compute a value and testing the formula
Program Plan:
- Define the main method.
- Declare variables for count of pods, count of peas and total peas.
- Display message to get count of pods.
- Store value for count of pods.
- Display message to get count of peas in pods.
- Store value for count of peas in pods.
- Compute value for total peas by multiplying both input values.
- Display the resultant value of total peas.
Program Description:
The following java program describes about creation of main method to implement a formula for computing value for total peas.
Explanation of Solution
Program:
//Include library
#include<iostream>
//Use namespace
using namespace std;
//Define main method
int main()
{
//Declare variables
int numberOfPods, peasPerPod, totalPeas;
//Define message
cout<<"Press return after entering a number"<<endl;
//Define message
cout<<"Enter the number of pods"<<endl;
//Store value
cin>>numberOfPods;
//Define message
cout<<"Enter the number of peas in a pod"<<endl;
//Store value
cin>>peasPerPod;
//Compute value
totalPeas = numberOfPods*peasPerPod;
//Define message
cout<<"If you have ";
//Define message
cout<<numberOfPods;
//Define message
cout<<" Peas pods"<<endl;
//Define message
cout<<"and ";
//Display message
cout<<peasPerPod;
//Define message
cout<<" Peas in each pod, then"<<endl;
//Define message
cout<<"You have ";
//Display value
cout<<totalPeas;
//Display message
cout<<" Peas in all the pods";
//Pause console window
system("pause");
//Return
return 0;
}
Press return after entering a number
Enter the number of pods
10
Enter the number of peas in a pod
15
If you have 10 Peas pods
and 15 Peas in each pod, then
You have 150 Peas in all the pods
Press any key to continue . . .
Want to see more full solutions like this?
Chapter 1 Solutions
Problem Solving with C++ (9th Edition)
Additional Engineering Textbook Solutions
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Software Engineering (10th Edition)
Database Concepts (8th Edition)
Modern Database Management (12th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
- Code with comments and output screenshot is must. I will Upvote. Thank you!arrow_forwardUse C++ Please provide screenshot of code. please include every detail and a code that can be copied and pasted. Thank you! This program will convert a set of temperatures from Fahrenheit to Celsius and Kelvin. Your program will be reading in three double values. The first values are starting and ending temperatures. The third value is the increment value. There is no prompt for the input. There is an error message that can be displayed. This is discussed later. You need to display output for all of the values between the starting and ending values. First two values are temperatures in Fahrenheit. You need to display all of the values from the first temperature to the last temperature. You increment from one temperature to the next by the increment value (the third value you read in). You need to convert these temperatures to Celsius and Kelvin. You need to output the temperatures as Fahrenheit, Celsius, and Kelvin. The numbers should be 18 characters wide with 4 digits of precision…arrow_forwardCreate a standard C++ program wherein it satisfies the following objectives 1.Create a menu. (Under the menu, it should display the following) *Testing *Information *Exit note: create a loop link between the menu and the program will only stop if the user chooses "exit". 2.I will provide the codes under the testing menu and it's up to you if you want to improve it a little further. 3. Under the information menu, the program will then ask the user for its name, address, age, and current relationship status, be creative and you can add small simple features to the program itself. Thanks a lot! Here's our first version program under the testing menu #include <iostream>using namespace std; int main() { bool hasFever; bool hasCough; bool breathingProblem; char input; cout << "WELCOME TO COVID-19 TRACKER \n \n" ; cout << "Does the patient have fever? (y/n) "; cin >> input; if (input == 'y' || input == 'Y') { hasFever =…arrow_forward
- Please review the image below. Produce the program in C++. Upload screenshots of Code and Output, as well as the source code. 7arrow_forwardPlease complete this program in C++ Please enusre that there is plenty of comments. PLENTY even if unessessary. Please include screenshots of actual code, screenshots of output, and code in the browser so I can copy and paste. Thank you.arrow_forwardPlease review the image below. Produce the program in C++. Upload screenshots of Code and Output, as well as the source code. 8arrow_forward
- Please review the image below. Produce the program in C++. Upload screenshots of Code and Output, as well as the source code. 4arrow_forwardThe code should be in C++, the hints for this are... 1. To search for a word in a line of text, you may use the find() function thatworks with C++ string objects.2. While implementing the search and replace functionality, you may need to makea temporary copy of the text file.arrow_forwardPlease answer: You are tasked to create a program on C++ that will enable the user to input first name, middle initial, and last name all in upper cases. with a 22-character limit that also includes spaces in between the names on the ID card. The following limitations should be included in the program:1.) If the first name, second name, middle initial, and last name exceed the character limit, use the first name initial and last name. 2.) If the last name’s character count is greater than or equal to the character limit, omit the second name and middle initial. Use the first name initial and truncate the last name to fit the character limit. 3.) The spaces in between the first name, second name, middle initial, and last name should not be included in the input. 4.) If there is no second name or middle initial, input 0. OUTOUT PROGRAM SHOULD BE: Type First Name: Type Second Name: Type Middle Name: Type Last Name: Result:arrow_forward
- C++ Programming It should align exactly like the screenshot, sample output. The local Driver’s License Office has asked you to write a program that grades the written portion of the driver’s license exam. The exam has 20 multiple choice questions. Here are the correct answers: 1. A2. D3. B4. B5. C6. B7. A8. B9. C10.D11. A12. C13. D14. B15. D16. C17. C18. A19. D20. B Your program should store the correct answers shown above in an array. It should ask the user to enter the student’s answers for each of the 20 questions, and the answers should be stored in another array. After the student’s answers have been entered, the program should display a message indicating whether the student passed or failed the exam. (A student must correctly answer 15 of the 20 questions to pass the exam.) It should then display the total number of correctly answered questions, the total number of incorrectly answered questions, and a list showing the question numbers of the incorrectly answered questions.…arrow_forwardC++ Problem: show code and steps Please and thank you. Recall the Temperature Program we created in Slide Set 01, Challenge Problem 01. Write a function that converts a temperature amount in Fahrenheit to Kelvin. Additionally, throw an error when the temperature entered is below 0ºK (i.e., absolute zero, the lowest possible temperature in the universe). Additionally, use try/catch to properly handle the thrown error to prevent the throw statement from crashing the program. Temperature Equivalencies 0ºK = -273.15ºC = -459.67ºFarrow_forwardPlease help me. Write this in C LANGUAGE. also provide ascreenshot that its working and just paste text of the source code. thank youarrow_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