Answer:
#include <iostream>
#include<iomanip>
using namespace std;
double DrivingCost(double drivenMiles, double milesPerGallon, double dollarsPerGallon)
{
double dollarCost = 0;
dollarCost = (dollarsPerGallon * drivenMiles) / milesPerGallon;
return dollarCost;
}
int main()
{
double miles = 0;
double dollars = 0;
cout << "Enter miles per Gallon : ";
cin >> miles;
cout << "Enter dollars per Gallon: ";
cin >> dollars;
cout << fixed << setprecision(2);
cout << endl;
cout << "Gas cost for 10 miles : " << DrivingCost(10, miles, dollars) << endl;
cout << "Gas cost for 50 miles : " <<DrivingCost(50, miles, dollars) << endl;
cout << "Gas cost for 400 miles: "<<DrivingCost(400, miles, dollars) << endl;
return 0;
}
Explanation:
- Create a method definition of DrivingCost that accepts three input double data type parameters drivenMiles, milesPerGallon, and dollarsPerGallon and returns the dollar cost to drive those miles
.
- Calculate total dollar cost and store in the variable, dollarCost
.
- Prompt and read the miles and dollars per gallon as input from the user
.
- Call the DrivingCost function three times for the output to the gas cost for 10 miles, 50 miles, and 400 miles.
Answer:
sendObject(John_Doe)
Explanation:
To invoke a method, simply call the name of the method, followed by it's arguments in parenthesis. i.e methodname(argument).
In this case, the name of the method is sendObject and it's argument is a Customer object stored in or referenced by a variable John_Doe.
The above is true since the method is defined in the same class that calls it. Otherwise, it is not valid.
Answer:
False
Explanation:
Input/output devices do NOT transfer information in only one direction.
Input devices receives the information while the output devices sends the information. The direction of the information being transferred between the input and output is NOT just in one direction.
Examples of input devices are keyboard, mouse, joy stick, scanner, etc.,
Examples of output devices are monitor (LED, LCD, CRT etc), printers (all types), plotters, projector, speaker(s), head phone, etc.