Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- int main()
- {
- char regNum[50], addCarsResult, hiRegNum[50];
- double price, totalPrice = 0, avgPrice, hiPrice = 0;
- int i, cheapCars = 0;
- bool addCars = true;
- for(i=1; i>0; i++ && !addCars){
- cout << "Enter the car registration number : " ;
- cin >> regNum;
- cout << "Enter the car price : RM ";
- cin >> price;
- if(price < 30000){
- cheapCars++;
- }
- if(price > hiPrice) {
- hiPrice = price;
- strcpy(hiRegNum, regNum);
- }
- totalPrice = totalPrice + price;
- cout << "Do you want to add another cars? (Y/N) : ";
- cin >> addCarsResult;
- cout << endl;
- if(addCarsResult == 'Y' || addCarsResult == 'y'){
- addCars;
- } else {
- addCars = !addCars;
- }
- if(addCars == false){
- break;
- }
- }
- avgPrice = totalPrice / i;
- cout << "Total Price = RM " << totalPrice << endl;
- cout << "Average Price : RM " << avgPrice << endl;
- cout << "The car with highest price is " << hiRegNum << " (Registration Number). The Price is RM " << hiPrice << endl;
- cout << "There are "<< cheapCars << " cheap cars with price below than RM30,000.00 " << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment