cs101 Assignment 2 Spring 2022
cs101 Assignment 2 Spring 2022
Course Cs101
Spring 2022
Question:1
Assume you own a car garage and want to maintain the log of the cars that are available
in your
garage. A car can be distinguished from other cars by the following attributes:
i. Car-Name
ii. Model
iii. Vendor
iv. Horse-Power
v. Price
vi. Owner-ID (Use your Student VUID here in the program)
Your goal is to develop a C++ program that implements a data structure named “Car”
(user defined data type) for the given scenario. Your program must have the following:
1. Define data structure named “Car” with all the above mentioned attributes.
2. Define appropriate variables within the data structure to store the above mentioned
attributes.
3. Take input from user for all attributes for a single car as given in the diagram below
and
store them in a “car” variable.
4. Display the Car information on screen as shown in the output diagram below.
Solution:
Code.
1 #include<iostream>
2 #include<cstdlib>
3 using namespace std;
4 int main()
5 {
6 char Car_Name[50],Car_Vender[50],Car_Owner_ID[50];
7 int Car_Model,Car_Horse_Power,Car_Price;
8 cout<<"Enter the Car Name:";
9 cin>> Car_Name;
10 cout<<"Enter the Car Model:";
11 cin>> Car_Model;
12 cout<<"Enter the Car Vender:";
13 cin>> Car_Vender;
14 cout<<"Enter the Horse Power:";
15 cin>> Car_Horse_Power;
16 cout<<"Enter the Car Price:";
17 cin>> Car_Price;
18 cout<<"Enter the Car Owner ID:";
19 cin>> Car_Owner_ID;
20 cout<<"Values are stored in Car variable:";
21 cout<<"\n\n";
22 cout<<"The store vehicle information is:"<<endl;
23 cout<<"Name:"<<Car_Name<<endl;
24 cout<<"Model:"<<Car_Model<<endl;
25 cout<<"Vender:"<<Car_Vender<<endl;
26 cout<<"Engine Power:"<<Car_Horse_Power<<endl;
27 cout<<"Price:"<<Car_Price<<endl;
28 cout<<"Owner ID:"<<Car_Owner_ID<<endl;
30 }
Screenshot;