rss
twitter
    Find out what You Want :)
Home    Downloads    Corner    Market    News sites    About Us

Sunday, April 17

Cs201 Assignment# 1 Solution

CS 2O1 Introduction To Programming
Assignment# 1 Solution
Semester Spring 2011


#include<iostream.h>
int amount(char, int);
main()
{
      int days;
      int rent;
      char model;
      char name[20];
      char carNo[10];
      cout << "Please provide cumstomer Name\t";
      cin >> name;
     
      cout << "\nPlease provide Car Model Description" << endl << endl;
      cout << "\tEnter 'A' for Model 2009.\n";
      cout << "\tEnter 'B' for Model 2010.\n";
      cout << "\tEnter 'C' for Model 2011.\n";
      cin >> model;
     
      cout << "\nplease provide following information:" << endl << endl;
      cout << "Car No:\t\t";
      cin >> carNo;
     
      cout << "Number of days\t";
      cin >> days;
      cout << endl << endl;
     
      switch(model)
      {
           case 'A':
           case 'a':
                      cout << "Customer Name:\t" << name << endl;
                      cout << "Car Model:\t2009" << endl;
                      cout << "Car No:\t\t" << carNo << endl;
                      cout << "Number of days:\t" << days << endl;
                      rent = amount(model, days);
                      cout << "Your Rental Amaount is:\t" << rent << endl;
           break;
           case 'B':
           case 'b':
                      cout << "Customer Name:\t" << name << endl;
                      cout << "Car Model:\t2010" << endl;
                      cout << "Car No:\t\t" << carNo << endl;
                      cout << "Number of days:\t" << days << endl;
                      rent = amount(model, days);
                      cout << "Your Rental Amaount is:\t" << rent << endl;
           break;
          
           case 'C':
           case 'c':
                      cout << "Customer Name:\t" << name << endl;
                      cout << "Car Model:\t2011" << endl;
                      cout << "Car No:\t\t" << carNo << endl;
                      cout << "Number of days:\t" << days << endl;
                      rent = amount(model, days);
                      cout << "Your Rental Amaount is:\t" << rent << endl;
           break;
          
           default:
                   cout << "please select only 2009, 2010, 2011 car models";
          
           }
      system("pause");
      }
    
int amount(char m, int d){
    if(m == 'A' || m == 'a')
    return (5000 * d);
   
    else if(m == 'B' || m == 'b')
    return (8000 * d);
       
    else if(m == 'C' || m == 'c')
    return (10000 * d);
    } 

No comments:

Post a Comment

Discus Your Study Problems Here

Is This Blog Is Useful For You?

Face Book Fans