Question

12. 13. Write a program that prompts the capacity, in gallons, of an automobile fuel tank and the miles per gallon the automo
0 0
Add a comment Improve this question Transcribed image text
Answer #1

12)

C++ program :-

#include <iostream>

using namespace std;

int main() {
int capacity;
int miles_p_gallon;
  
cout<<"Enter the capacity in gallons :"<<endl;
cin>>capacity;
  
cout<<"Enter miles per gallons :"<<endl;
cin>>miles_p_gallon;
  
double no_of_miles;
  
no_of_miles = (double)capacity/(double)miles_p_gallon;
  
cout<<"The no. of miles the vehicle can drive without refueling : "<<no_of_miles<<endl;
}

Output :-

✓ Execute Mode, Version, Inputs & Arguments GCC 9.1.0 Stdin Inputs Interactive Command Line Arguments 100 11 Execute ... G Re

13)

C++ program :-

#include <iostream>

using namespace std;

int main() {
int user_seconds;
int miles_p_gallon;
  
cout<<"Enter the elapsed seconds time :"<<endl;
cin>>user_seconds;
  
int seconds;
int minutes;
int hours;
  
seconds = user_seconds%60;
minutes = user_seconds/60;
hours= minutes/60;
minutes=minutes%60;
  
cout<<"The time : "<<hours<<":"<<minutes<<":"<<seconds<<endl;
}

Output :-

V Execute Mode, Version, Inputs & Arguments GCC 9.1.0 Interactive Stdin Inputs 9630 CommandLine Arguments Execute Result CPU

Add a comment
Know the answer?
Add Answer to:
12. 13. Write a program that prompts the capacity, in gallons, of an automobile fuel tank...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • in c++ program Write a C + + program that prompts the user to input the...

    in c++ program Write a C + + program that prompts the user to input the elapsed time for an event in seconds. The program then outputs the elapsed time in hours, minutes, and seconds. (For example, if the elapsed time is 9630 seconds, then the output is 2:40:30.)

  • Q2 Write pseudocode and flow chart of the following problem Qi. Write pseudocode and flow chart...

    Q2 Write pseudocode and flow chart of the following problem Qi. Write pseudocode and flow chart that prompts (input) the capacity, in gallons, of an automobile fuel tank and the miles per gallon the automobile can be driven. The program outputs the number of miles the automobile can be driven without refueling. Q ii. Centigrade and Fahrenheit are two scales to measure temperature. Write pseudocode and flow chart that that prompts (input) the user to enter Centigrate and then print...

  • Write program PSEUDOCODE that prompts the user for their name and then will compute a car's...

    Write program PSEUDOCODE that prompts the user for their name and then will compute a car's miles per gallon given input of miles driven and gallons of gas used. It should also convert those given numbers into metric and show kilometers driven, liters used, and kilometers per liter. All with well formatted output. Submit: C++ Programming Warm-Up Exercise PSEUDOCODE for the algorithm that compute's a car's miles per gallon given input of miles and convert these numbers into metric and...

  • Write a program that prompts the user to enter a person's birth date in numeric form...

    Write a program that prompts the user to enter a person's birth date in numeric form (e.g. 8-27-1980) and outputs the date of birth in the format of month day, year (e.g. August 27, 1980). Your program must work for three types of exceptions - invalid day, invalid month and invalid year (year must be between 1915 and 2015). Make these as class driven exceptions. Use one try-catch block with separate catches for the exception classes to handle errors for...

  • Write a program that prompts the user to enter the number of milliseconds and converts the milliseconds to a string hours:minutes:seconds

    Problem 1.Write a program that prompts the user to enter the number of milliseconds and converts the milliseconds to a string hours:minutes:seconds. The program should use the convertMillismethod with the following header:public static String convertMillis(long millis)For example, convertMillis(5500) returns the string 0:0:5, convertMillis(100000) returns the string 0:1:40, andconvertMillis(555550000) returns the string154:19:10.Problem 2. (Count occurrence of numbers)Write a program that reads integers between 1 and 100 and counts the occurrence of each (you should store the numbers in an array). Output...

  • Intro to C++ For this program, again use Program 4-18 in the text as an example....

    Intro to C++ For this program, again use Program 4-18 in the text as an example. Assume you're writing this menu-driven program for a shipping company. There are two types of shipments: normal and expedited. a. As shown in Program 4-18, please declare constants for the types of shipments. Please write the names of constants in ALL CAPS. b. Show the menu in a clear form, and prompt the user for the type of shipment; the rest of the program...

  • USING PYTHON IDLE 3.4: NEED HELP WITH THIS PLEASE! :( Question #8: You want to determine...

    USING PYTHON IDLE 3.4: NEED HELP WITH THIS PLEASE! :( Question #8: You want to determine the distance to lightning strikes during a storm. This can be measured using the time elapsed between seeing the lightning flash and hearing the thunder. You know that the speed of sound is approximately 1,100 ft/second and 1 mile is 5,280 feet. Write a program named q8.py that prompts the user for the number of lightning strikes to analyze and the number of seconds...

  • 1 Write a program to convert the time from 24-hour notation to 12-hour notation and vice...

    1 Write a program to convert the time from 24-hour notation to 12-hour notation and vice versa. Your program must be menu driven, giving the user the choice of converting the time between the two notations. Furthermore, your program must contain at least the following functions: a function to convert the time from 24-hour notation to 12-hour notation, a function to convert the time from 12-hour notation to 24-hour notation, a function to display the choices, function(s) to get the...

  • python question Question 1 Write a Python program to play two games. The program should be...

    python question Question 1 Write a Python program to play two games. The program should be menu driven and should use different functions to play each game. Call the file containing your program fun games.py. Your program should include the following functions: • function guess The Number which implements the number guessing game. This game is played against the computer and outputs the result of the game (win/lose) as well as number of guesses the user made to during the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT