C++ Structure

  • Uploaded by: Mahathir Mohmed
  • 0
  • 0
  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View C++ Structure as PDF for free.

More details

  • Words: 231
  • Pages: 3
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

Related Documents

C++ Structure
November 2019 24
Structure
April 2020 17
Structure
April 2020 20
Structure
October 2019 31

More Documents from ""

Green Quotes
December 2019 28
December 2019 36
Root Explant
November 2019 31
Botox
November 2019 32