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++ plus MyProgrammingLab with Pearson eText-- Access Card Package (9th Edition)
Additional Engineering Textbook Solutions
Introduction To Programming Using Visual Basic (11th Edition)
SURVEY OF OPERATING SYSTEMS
Starting Out with Python (4th Edition)
Database Concepts (8th Edition)
Mechanics of Materials (10th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
- Find the error: daily_sales = [0.0, 0,0, 0.0, 0.0, 0.0, 0.0, 0.0] days_of_week = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] for i in range(7): daily_sales[i] = float(input('Enter the sales for ' \ + days_of_week[i] + ': ')arrow_forwardFind the error: daily_sales = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] days_of_week = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] for i in range(6): daily_sales[i] = float(input('Enter the sales for ' \ + days_of_week[i] + ': '))arrow_forwardWhat are the steps you will follow in order to check the database and fix any problems with it and normalize it? Give two references with your answer.arrow_forward
- What are the steps you will follow in order to check the database and fix any problems with it? Have in mind that you SHOULD normalize it as well. Consider that the database offline is not allowed since people are connected to it and personal data might be bridged and not secured. Provide three refernces with you answer.arrow_forwardShould software manufacturers should be tolerant of the practice of software piracy in third-world countries to allow these countries an opportunity to move more quickly into the information age? Why or why not?arrow_forwardI would like to know about the features of Advanced Threat Protection (ATP), AMD-V, and domain name space (DNS).arrow_forward
- I need help to resolve the following activityarrow_forwardModern life has been impacted immensely by computers. Computers have penetrated every aspect of oursociety, either for better or for worse. From supermarket scanners calculating our shopping transactionswhile keeping store inventory; robots that handle highly specialized tasks or even simple human tasks,computers do much more than just computing. But where did all this technology come from and whereis it heading? Does the future look promising or should we worry about computers taking over theworld? Or are they just a necessary evil? Provide three references with your answer.arrow_forwardWhat are the steps you will follow in order to check the database and fix any problems with it? Have in mind that you SHOULD normalize it as well. Describe in full, consider the following:• Taking the database offline is not allowed since people are connected to it.• Personal data might be bridged and not secured. Provide three refernces with you answerarrow_forward
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage