C plus plus read cost, year and quantity cost for 10 items
main.cpp
#include<iostream>
using namespace std;
int main(){
const int size = 10;
double cost[size];
int yearofmanufacture[size];
int soldcount[size];
int i;
double total = 0;
double price = 0;
double rate = 0;
cout << "Enter the cost for all " << size << " types of items, separated by a space" << endl;
for(i = 0; size > i; i ++){
cin >> cost[i];
}
cout << "Enter the year of manufacture for all " << size << " types of items, separated by a space" << endl;
for(i = 0; size > i; i ++){
cin >> yearofmanufacture[i];
}
cout << "Enter the number of items for all " << size << " types of items, separated by a space" << endl;
for(i = 0; size > i; i ++){
cin >> soldcount[i];
}
for(i = 0; size > i; i ++){
rate = 0;
if(1991 <= yearofmanufacture[i] && 2000 >= yearofmanufacture[i]){
rate = 40;
} else if(2001 <= yearofmanufacture[i] && 2010 >= yearofmanufacture[i]){
rate = 20;
} else if(2011 <= yearofmanufacture[i] && 2017 >= yearofmanufacture[i]){
rate = 10;
}
price = (cost[i] * soldcount[i]);
price -= (rate/100);
total += price;
}
cout << "The total revenue earned is: $" << total << endl;
return 0;
}
Download code here.
Comments
Post a Comment