Problem statement: Based on an automobile's model year and weight the state of New Jersey determines the car's weight class and registration fee using the following schedule
Model Year | Weight | Weight Class | Registration Fee |
1970 or earlier | Less than 2700 lbs | 1 | $16.50 |
2700 to 3800 lbs | 2 | $25.50 | |
More than 3800 lbs | 3 | $46.50 | |
1971 to 1979 | Less than 2700 lbs | 4 | $27.00 |
2700 to 3800 lbs | 5 | $30.50 | |
More than 3800 lbs | 6 | $52.50 | |
1980 or later | Less than 3500 lbs | 7 | $19.50 |
3500 or more lbs | 8 | $52.50 |
Using this information, write C++ program that accepts the year and weight of an automobile and determines and displays the weight class and registration fee for the car.
CODE:
/**
Laboratory Exercise #4
CS10-B5
@author Red Berroy
*/
#include <iostream.h>
Laboratory Exercise #4
CS10-B5
@author Red Berroy
*/
#include <iostream.h>
int main ()
{
int m_year,weight;
//Variable names
int m_year,weight;
//Variable names
cout<<"Enter the year model: ";
cin>>m_year;
//Enter year model
cin>>m_year;
//Enter year model
cout<<"Enter the weight of the car: ";
cin>>weight;
//Enter weight
if (weight < 2700 && m_year <= 1970)
{
cout<<"Your weight class is 1"<<endl;
cout<<"Your registration fee is $16.50"<<endl;
}
else if (weight >= 2700 && weight <= 3800 && m_year <= 1970)
{
cout<<"Your weight class is 2"<<endl;
cout<<"Your registration fee is $25.50"<<endl;
}
else if (weight > 3800 && m_year <= 1970)
{
cout<<"Your weight calss is 3"<<endl;
cout<<"Your registration fee is $46.50"<<endl;
}
else if (weight < 2700 && m_year > 1970 && m_year < 1980)
{
cout<<"Your weight class is 4"<<endl;
cout<<"Your registration fee is $27.00"<<endl;
}
else if (weight >= 2700 && weight <= 3800 && m_year > 1970 && m_year < 1980)
{
cout<<"Your weight class is 5"<<endl;
cout<<"Your registration fee is $30.50"<<endl;
}
else if (weight > 3800 && m_year > 1970 && m_year < 1980)
{
cout<<"Your weight class is 6"<<endl;
cout<<"Your registration fee is $52.50"<<endl;
}
else if (weight < 3500 && m_year >= 1980)
{
cout<<"Your weight class is 7"<<endl;
cout<<"Your registration fee is $19.50"<<endl;
}
else if (weight >= 3500 && m_year >= 1980)
{
cout<<"Your weight class is 8"<<endl;
cout<<"Your registration fee is $52.50"<<endl;
}
return 0;
}
cin>>weight;
//Enter weight
if (weight < 2700 && m_year <= 1970)
{
cout<<"Your weight class is 1"<<endl;
cout<<"Your registration fee is $16.50"<<endl;
}
else if (weight >= 2700 && weight <= 3800 && m_year <= 1970)
{
cout<<"Your weight class is 2"<<endl;
cout<<"Your registration fee is $25.50"<<endl;
}
else if (weight > 3800 && m_year <= 1970)
{
cout<<"Your weight calss is 3"<<endl;
cout<<"Your registration fee is $46.50"<<endl;
}
else if (weight < 2700 && m_year > 1970 && m_year < 1980)
{
cout<<"Your weight class is 4"<<endl;
cout<<"Your registration fee is $27.00"<<endl;
}
else if (weight >= 2700 && weight <= 3800 && m_year > 1970 && m_year < 1980)
{
cout<<"Your weight class is 5"<<endl;
cout<<"Your registration fee is $30.50"<<endl;
}
else if (weight > 3800 && m_year > 1970 && m_year < 1980)
{
cout<<"Your weight class is 6"<<endl;
cout<<"Your registration fee is $52.50"<<endl;
}
else if (weight < 3500 && m_year >= 1980)
{
cout<<"Your weight class is 7"<<endl;
cout<<"Your registration fee is $19.50"<<endl;
}
else if (weight >= 3500 && m_year >= 1980)
{
cout<<"Your weight class is 8"<<endl;
cout<<"Your registration fee is $52.50"<<endl;
}
return 0;
}
0 comments:
Post a Comment