1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Makovka662 [10]
4 years ago
13

Write a C++ program that prompt the user to enter the distance to drive, the fuel efficiency of the car in miles per gallon, and

the price per gallon, and displays the cost of the trip.
Computers and Technology
1 answer:
Mazyrski [523]4 years ago
4 0

Answer:

Here is the code in c++.

//include headers

#include <bits/stdc++.h>

using namespace std;

int main() {

//variables to store input

float dis,fuel_effi,price_gall;

cout<<" Enter total distance of the  trip: ";

//read distance

cin>>dis;

cout<<" fuel efficiency of car( miles per gallon):";

//read fuel efficiency

cin>>fuel_effi;

cout<<" price of fuel (per gallon):";

//read price of fuel

cin>>price_gall;

// calculate total cost of trip

float tot_cost=dis*price_gall/fuel_effi;

cout<<"Total cost of the trip is: "<<tot_cost<<endl;

return 0;

}

Explanation:

First read distance to travel, fuel efficiency of the car and price of fuel per gallon.To find the total cost of the trip, we use the formula total cost=dis*price_gall/fuel_effi. Where "dis" is total distance of trip, "price_gall" is price of fuel per gallon and "fuel_effi" is fuel efficiency of the car. The mentioned formula gives the total cost of the trip.

Output:

Enter total distance of the  trip: 120

fuel efficiency of car( miles per gallon):30

price of fuel (per gallon):100                                                                                                                      

Total cost of the trip is: 400

You might be interested in
You want to create a place on a Webpage where you can display graphics, animation, video and games "on the fly" without the need
AURORKA [14]

Answer:

Canvas.

Explanation:

The canvas API is used to create a place where you can display graphics on a webpage. You can also display video,games and animations there on the fly .You can do this without the need for a plug-in.

It is largely focused on 2-D graphics.This API uses canvas element of HTML.

<canvas>....</canvas>.

4 0
3 years ago
1. ____________notes that can be attached to cells to add additional information that is not printed on the worksheet network dr
Anna71 [15]

1. <u>Comments</u> notes that can be attached to cells to add additional information that is not printed on the worksheet network drive.

2. <u>Footer</u> text and/or graphics that print at the bottom of each page headers.

3. <u>Headers</u> text and/or graphics that print at the top of each page rows.

4. <u>Margins</u> the white space left around the edges of the paper when a worksheet is printed comments.

5. <u>Network drive</u> location at a workplace for storing computer files footer.

6. <u>Rows</u> go across (horizontal) margins.

7. <u>Template</u> a file format used to create new files that contain the same data as the template.

<u>Explanation:</u>

On the off chance that you need to add a header or footer to all sheets, select each sheet by right-clicking one of the sheet tabs at the base of the Excel screen and clicking "Select All Sheets" in the spring up menu. It's genuinely basic to put an Excel header on all pages of all worksheets in your record.

A header is a line of content that shows up at the highest point of each page of a printed worksheet. You can change the direction of a worksheet, which is the situation of the substance with the goal that it prints either vertically or on a level plane on a page.

6 0
4 years ago
My friend Leo wants to have an emergency plan for his final exams on University of Southern Algorithmville. He has N subjects to
leonid [27]

Answer:

Greedy is an algorithmic paradigm that builds up a solution piece by piece, always choosing the next piece that offers the most obvious and immediate benefit. Greedy algorithms are used for optimization problems. An optimization problem can be solved using Greedy if the problem has the following property: At every step, we can make a choice that looks best at the moment, and we get the optimal solution of the complete problem.

If a Greedy Algorithm can solve a problem, then it generally becomes the best method to solve that problem as the Greedy algorithms are in general more efficient than other techniques like Dynamic Programming. But Greedy algorithms cannot always be applied. For example, the Fractional Knapsack problem (See this) can be solved using Greedy, but 0-1 Knapsack cannot be solved using Greedy.

The following are some standard algorithms that are Greedy algorithms.

1) Kruskal’s Minimum Spanning Tree (MST): In Kruskal’s algorithm, we create an MST by picking edges one by one. The Greedy Choice is to pick the smallest weight edge that doesn’t cause a cycle in the MST constructed so far.

2) Prim’s Minimum Spanning Tree: In Prim’s algorithm also, we create an MST by picking edges one by one. We maintain two sets: a set of the vertices already included in MST and the set of the vertices not yet included. The Greedy Choice is to pick the smallest weight edge that connects the two sets.

3) Dijkstra’s Shortest Path: Dijkstra’s algorithm is very similar to Prim’s algorithm. The shortest-path tree is built up, edge by edge. We maintain two sets: a set of the vertices already included in the tree and the set of the vertices not yet included. The Greedy Choice is to pick the edge that connects the two sets and is on the smallest weight path from source to the set that contains not yet included vertices.

4) Huffman Coding: Huffman Coding is a loss-less compression technique. It assigns variable-length bit codes to different characters. The Greedy Choice is to assign the least bit length code to the most frequent character. The greedy algorithms are sometimes also used to get an approximation for Hard optimization problems. For example, the Traveling Salesman Problem is an NP-Hard problem. A Greedy choice for this problem is to pick the nearest unvisited city from the current city at every step. These solutions don’t always produce the best optimal solution but can be used to get an approximately optimal solution.

6 0
3 years ago
What game is this??????????????????????
miss Akunina [59]

Answer:

rocket league

Explanation: cars and balls

7 0
3 years ago
What is the significance of both RAID and IP technologies as precursors to the SAN environment?
Dominik [7]

Explanation:SAN(Storage area network) technology is the network technology that is used for the accessing of the block level network towards the storage units. It is made up of the storage components, switches etc.

RAID(Redundant Array of Independent Disks) and IP(internet protocol) is used as the precursor because they work better than the SAN. They have the ability to solve the issue that occur in the SAN technology like complexity,and other faulty issues.They maintain the fault tolerance quality and maintaining the network.

3 0
4 years ago
Other questions:
  • A ________ is when teachers develop a professional based network of people selected by him/her to pursue learning needs and shar
    12·1 answer
  • What might happen if a computer has too many applications running at one time?
    15·1 answer
  • List four useful spreadsheet functions and explain what they do.
    11·1 answer
  • Ethan is a systems developer. He is working on a system where he will implement independent solutions for different processes. W
    7·1 answer
  • Knowledge and experience help you
    11·1 answer
  • Can somebody help me and make a code for this in PYTHON, please? I would be very thankful!
    10·1 answer
  • How do you give brainlest things out?
    14·2 answers
  • --------------------------------------------------------------------------------------------------------------------------------
    8·1 answer
  • What can visible light and ultraviolet light do together
    14·1 answer
  • Please can someone solve this question<br>What is a software and types of software​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!