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

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;

}

Posted Date: 2/15/2013 7:04:16 AM | Location : United States







Related Discussions:- Write a c program that accepts the year and weight , Assignment Help, Ask Question on Write a c program that accepts the year and weight , Get Answer, Expert's Help, Write a c program that accepts the year and weight Discussions

Write discussion on Write a c program that accepts the year and weight
Your posts are moderated
Related Questions
Define the Relational Operator in c language? The Relational operators refer to the relationships that values can have with one another and they are used to compare two operand


Inline Functions Imagine a c program, which reads disk records having employee information. If this is a payroll application each employee record data is probably processed by

Write a C++ program according to the following specifications 1. Display a brief description of the program. 2. Ask the user to specify the type of loading (end load, intermediate

Write a Program to illustrate the Call by Reference? Here is an illustration: #include . int compute_sum(int *n); int main( void) { int n=3, sum; printf("%d\n",n); /

Explain each of the algorithms in a way that would be understandable to an intelligent person who is not familiar with programming. You should not use any code (or even pseudo code

We are now quite happy to use the basic mathematical expressions, however in engineering we use scientific functions i.e Sin , Cos  , ln etc . Within C we have the following functi

In this assignment you are required to develop a program that allows the creation, viewing and storage of information about ITECH7603 Students. In order to complete the task you ha

Spider webs have two types of silk, sticky silk and strength silk, spiders do not move on the sticky silken threads only on the strength threads. Assume one type of spider creates

smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send