Suppose you have to design a program using the C++ language to determine the car that corresponds to the price that your program calculated. The price of the car is determined by adding three(3) prices: which are engine price, colour price and the price based on the power of the car. The engine price ranges R500 000 – R2000000 The colour of the car ranges R7000 – R10000 The price based on the power of the car ranges R300 000 – R600 000 If the sum of the three(3) prices is between R700 000 – R1000000, the program must display that the car is in the range of a VW Golf 8 GTI If the sum of the three(3) prices is between R1100000-1800000, the program must display that the car is in the range of a Mercedes Benz GLC63s If the sum of the three(3) prices is between R1900 000 – R2500000, the program must display that the car is in a range of a BMW M8 challenger: 1. Write the Pseudocode for your program 2. Draw the flowchart for tracing your program steps
#include<bits/stdc++.h>
using namespace std;
int main()
{
unsigned int eng_price,color_price,power,total;
cout<<"Enter Engine price : ";
cin>>eng_price;
cout<<"Enter color price : ";
cin>>color_price;
cout<<"Enter the price based on the power of the car : ";
cin>>power;
total=eng_price+color_price+power;
if(total>700000 && total<1000000)
{
cout<<"The car is in the range of a VW Golf 8 GTI";
}
else
{
if(total>1100000 && total<1800000)
{
cout<<"The car is in the range of a Mercedes Benz GLC63s";
}
else
{
if(total>1900000 && total<2500000)
{
cout<<"The car is in a range of a BMW M8 challenger";
}
else
{
cout<<"Invalid price";
}
}
}
}
Comments
Leave a comment