Complete pseudocode, flowchart, c++ for the following programs: Create a program
ID: 3546814 • Letter: C
Question
Complete pseudocode, flowchart, c++ for the following programs:
Create a program using a loop that reads in a list of positive integers from the user until the user enters the value -1 as a sentinal.
At that time the program should display the largest value in the input list.
Create a program to calculate and display commission based on the amount of sale that the user enters. The commission rate is 12%. Using a loop, continue to calculate and display the commission until the user enters a -1 for the amount of sales.
Explanation / Answer
/**************** PROGRAM 1 ******************************/
#include <iostream>
using namespace std;
int main()
{
int i, max = -1;
while (true) {
cin >> i;
if (i == -1) break;
if (i > max) max = i;
}
cout << "max : " << max << endl;
return 0;
}
/**************** PROGRAM 2 ******************************/
#include <iostream>
using namespace std;
int main()
{
float amount, comm;
while (true) {
cin >> amount;
if (amount == -1) break;
comm = 0.12 * amount;
cout << comm << endl;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.