ACTIVITY 4 Based on the image attached, answer the following questions using C++ language. > numberOfPods; cout > peasPerPod; totalPeas = numberOfPods * peasPerPod; cout #include using namespace std;...



ACTIVITY 4


Based on the image attached, answer the following questions using C++ language.



#include <iostream><br>using namespace std;<br>int main( )<br>{<br>int numberOfPods, peasPerPod, totalPeas;<br>cout << > numberOfPods; cout < "enter="" the="" number="" of="" peas="" in="" a="" pod:\n";="" cin="">> peasPerPod; totalPeas = numberOfPods * peasPerPod; cout < "if="" you="" have="" ";="" cout="">< numberofpods;="" cout="">< "="" pea="" pods\n";="" cout="">< "and="" ";="" cout="">< peasperpod;="" cout="">< "="" peas="" in="" each="" pod,="" then\n";="" cout="">< "you="" have="" ";="" cout="">< totalpeas;="" cout="">< "="" peas="" in="" all="" the="" pods.\n";="" return="" 0;="" "/="">
Extracted text: #include using namespace std; int main( ) { int numberOfPods, peasPerPod, totalPeas; cout < "press="" return="" after="" entering="" a="" number.\n";="" cout="">< "enter="" the="" number="" of="" pods:\n";="" cin="">> numberOfPods; cout < "enter="" the="" number="" of="" peas="" in="" a="" pod:\n";="" cin="">> peasPerPod; totalPeas = numberOfPods * peasPerPod; cout < "if="" you="" have="" ";="" cout="">< numberofpods;="" cout="">< "="" pea="" pods\n";="" cout="">< "and="" ";="" cout="">< peasperpod;="" cout="">< "="" peas="" in="" each="" pod,="" then\n";="" cout="">< "you="" have="" ";="" cout="">< totalpeas;="" cout="">< "="" peas="" in="" all="" the="" pods.\n";="" return="">
1. Using your text editor, enter (that is, type in) the C++ program shown above<br>2. Change the program so that it asks a user for their favourite number, writes it to the<br>screen and then goes on to do the same things that the program in Q1 does. Create an int<br>variable to store the number and read a value from the user using cin. Print out the text

Extracted text: 1. Using your text editor, enter (that is, type in) the C++ program shown above 2. Change the program so that it asks a user for their favourite number, writes it to the screen and then goes on to do the same things that the program in Q1 does. Create an int variable to store the number and read a value from the user using cin. Print out the text "Your favourite number is:" and the number that the user has entered. Be certain to add the symbols \n to your output statement. If the user entered 42, you should print out “Your favourite number is 42". Recompile the changed program and run it.

Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here