QUESTION Given declaration as below: struct vehicle { char plate_no[8]; char type[25]; char manufacturer[25]; double price, tax_rate, road_price; }car; Write a C++ program to accomplish the following questions: a. Input value from user for the structure element plate_no, type, manufacturer and price for structure variable car b. Assign value 0.25 for structure element tax_rate for structure variable car c. According to the structure element tax_rate, calculate the road_price for structure variable car where tax = price * tax_rate road_price = price + tax d. Display the entire structure element for car by following this format: Plate No Type Manufacturer Price Tax Rate Road Price :
: : : : :
ANSWER source code /* Name : xxx Date : 130308 Description : Lab 5 Made with Dev C++ 4.9.9.2 */ #include #include using namespace std; struct vehicle { char plate_no[8]; char type[25]; char manufacturer[25]; double price, tax_rate, road_price; }car; int main() {//open main float tax; //get input cout<<"\n\tPlate Number cin.getline(car.plate_no,8);
: ";
cout<<"\n\tType of Vehicle cin.getline(car.type,25);
: ";
cout<<"\n\tManufacturer : "; cin.getline(car.manufacturer,25); cout<<"\n\tPrice cin>>car.price; //compute car.tax_rate = 0.25; tax = car.price * car.tax_rate; car.road_price = car.price + tax;
: RM ";
//display result cout<<"\n\t..........................................."<<endl; cout<<"\n\tPlate Number cout<<"\n\tType of Vehicle cout<<"\n\tManufacturer cout<<"\n\tPrice cout<<"\n\tTax Rate cout<<"\n\tTax Value cout<<"\n\tRoad Price
: "<
cout<<"\n\t..........................................."<<endl<<endl; system("pause"); } console application