فناوري اطلاعات و ارتباطات
ماشين حساب
نوشته شده توسط sunup در ساعت 05:11

زبان ++ C


/*
Author: Wilton Marranzini
Objective: Program calculates the fule effiency of the car on the trip in
miles/gallon and the cost for gasoline at the end of the trip.
*/
#include //including lib.
#include //including lib.
#include //including lib.
//Prototypes functions
void description();//Description cout fuction.
float full_efficiency(int miles, int gallons);//efficiency function.
float cost(float price, int gallons); //Cost function.
int main()//Main Function

    { string gas_station;//String for gas station name.
    int num_miles; // Variable for number of miles
    int num_gallons;//Variable for number of gallons.
    float price_per_gallons;//Variable for price per gallons.
    float efficiency; //variable for efficiency.
    float cos; //variable for cost
    int a; //keeps screen function
    description(); //Discription function
    cout<< "Enter gas station name\n";
    getline(cin, gas_station); //Getting gas station title
    cout<< "Name of gas station Is " << gas_station <<".\n";
    cout<     cout<< "Enter the numbers of miles travel.\n";
    cin>>num_miles;//storing numbers of miles
    cout<< "Enter the number of gallons of gasoline purchased.\n";
    cin>>num_gallons;//storing number of gallons
    cout<< "Enter the Price per gallons.\n";
    cin>>price_per_gallons;//storing price per gallons
    efficiency = full_efficiency(num_miles,num_gallons);//calling function.
    cos =cost(price_per_gallons,num_gallons);//calling function.
    cout<<"The efficiency is "<     <     cout<<"Gallons used on the trip is "<     <<"is "<<"$"<< cos <     cin>>a; //keeps screen open
    return 0;//returning value
}

void description()

    {
     cout<< "Program calculates the fule effiency of the car on the trip\n"
     << "in miles/gallon and the cost for gasoline at the end of the\n"
    << "trip.\n";
}

float full_efficiency(int miles, int gallons)

    {
     float efficien; //efficiency variable
     efficien = miles/gallons;
     return (efficien);//returning value
}

float cost(float price, int gallons)

    {
     float charge;//charge variable
    charge = price*gallons;
    return (charge); //returning value
} 
 


ورود کاربران

خوش آمدید! لطفا وارد حساب خود شوید

رمز عبور را فراموش کرده‌اید؟
حساب کاربری ندارید؟

فراموشی رمز عبور

نام کاربری یا ایمیل خود را وارد کنید

یا

ثبت نام کاربران

در چند ثانیه حساب کاربری خود را بسازید

قبلا ثبت نام کرده‌اید؟

نظرات کاربران

دیدگاه خود را با ما در میان بگذارید