Write a c program that accepts the year and weight , C/C++ Programming

Assignment Help:

Based on the automobile's model year and weight, the city of Cebu determines the car's weight class and registration fee using the following schedule:

Model Year Registration              Weight                     Weight Class                      Fee(pesos)

1970 or earlier                 less than 2,700 lbs                 1                        500.00

                                       2,700 to 3,800 lbs                2                         700.00

                                     more than 3,800 lbs               3                         900.00

1971 to 1979                    less than 2,700 lbs               4                         1,100.00

                                       2,700 to 3,800 lbs                5                         1,300.00

                                     more than 3,800 lbs              6                           1,500.00

1980 or later                   less than 3,500 lbs               7                            2,000.00

                                       3,500 or more lbs               8                            2,500.00

Using this information, write a C program that accepts the year and weight of an automobile and determines and displays the weight class and registration fee for the car. 

#include

#include

using namespace std;

int main(int argc, char *argv[])

{

/* Declare variables */

int year, weight;

int class = 0;

/* Obtain input from user*/

cout<<"Enter the year of the car: ";

cin>>year;

cout<<"Enter the weight of the car in pounds: ";

cin>>weight;

/* Perform registration fee calculation*/  

if (weight < 2700 && year <= 1970)

   class=1;

else if (weight >= 2700 && weight <= 3800 && year <= 1970)

   class=2;

else if (weight > 3800 && year <= 1970)

   class=3;

else if (weight < 2700 && year > 1970 && year < 1980)

   class=4;

else if (weight >= 2700 && weight <= 3800 && year > 1970 && year < 1980)

   class=5;

else if (weight > 3800 && year > 1970 && year < 1980)

   class=6;

else if (weight < 3500 && year >= 1980)

   class=7;

else (weight >= 3500 && year >= 1980)

   class=8;

     switch (class)

{

       case 1:

            cout<<"Your registration fee is $16.50";

            break;

       case 2:

            cout<<"Your registration fee is $25.50";

            break;

       case 3:

            cout<<"Your registration fee is $46.50";

            break;

       case 4:

            cout<<"Your registration fee is $27.00";

            break;

       case 5:

            cout<<"Your registration fee is $30.50";

            break;

       case 6:

            cout<<"Your registration fee is $52.50";

            break;

       case 7:

            cout<<"Your registration fee is $19.50";

            break;

       case 8:

            cout<<"Your registration fee is $52.50";

            break;

}     

    system("PAUSE");

    return EXIT_SUCCESS;

}


Related Discussions:- Write a c program that accepts the year and weight

Program of binary tree, Program of Binary tree: Btree::Btree(int O) : ...

Program of Binary tree: Btree::Btree(int O) : itemsInContainer(0) {     finishInit(O); }   Btree::~Btree(void) {     if( root != 0 )         delete roo

Develop a complex app, Project Description: I would like to be building ...

Project Description: I would like to be building regarding a complex mobile application build as we require the signing of an NDA. My firm in based in Montreal Canada and we are

#Padovan string, A Padovan string P(n) for a natural number n is defined as...

A Padovan string P(n) for a natural number n is defined as: P(0) = ‘X’ P(1) = ‘Y’ P(2) = ‘Z’ P(n) = P(n-2) + P(n-3), n>2 where + denotes string concatenation. For a string of the c

Source code on home stay, I am doing project on home stay which includes fe...

I am doing project on home stay which includes features like add homestay,search,book,delete homestay,

Genetic disease, Many human diseases could be controlled by the knowledge o...

Many human diseases could be controlled by the knowledge of the gene’s structure and pattern. The human gene could be represented by four nucleotides. Each nucleotide is represente

Explain about the character constants in c language, Explain about the Char...

Explain about the Character Constants in c language? The character constant is a single alphabet and a single digit or a single special symbol enclosed within a pair of single

Algorithm, Write a algorithm to explain the processof wakingbup in morning

Write a algorithm to explain the processof wakingbup in morning

Poop, hwat is the area fsdjlakl;aeklfjtealrtl;gka

hwat is the area fsdjlakl;aeklfjtealrtl;gka

Write the statements which are used to connect php, Write the statements wh...

Write the statements which are used to connect PHP with MySQL? Statements which can be used to connect PHP with MySQL is: $conn = mysql_connect('localhost'); echo $co

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd