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
meriva
3 years ago
8

Write a program that declares a constant named QUARTS_IN_GALLON which holds the number of quarts in a gallon (4). Also declare a

variable named quartsNeeded to represent the number of quarts needed for a painting job, and assign an appropriate value. Compute and display the number of gallons and quarts needed for the job. Display explanatory text with the values—for example, A job that needs 18 quarts requires 4 gallons plus 2 quarts.
Computers and Technology
1 answer:
Hunter-Best [27]3 years ago
5 0

Answer:

The c++ program for the given scenario is shown below.

#include <iostream>

using namespace std;

int main() {

   // value is mentioned in the question

   const int QUARTS_IN_GALLON = 4;

   // any positive integer value can be assigned

   int quartsNeeded = 25;

   int gallons, quarts;

   // 0 will be assigned if quartsNeeded is less than QUARTS_IN_GALLON

   gallons = quartsNeeded/QUARTS_IN_GALLON;

   // 0 will be assigned if quartsNeeded is completely divisible by QUARTS_IN_GALLON

   quarts = quartsNeeded%QUARTS_IN_GALLON;

   cout << "A job that needs " << quartsNeeded << " quarts requires " << gallons << " gallons plus " << quarts << " quarts." << endl;

   return 0;

}

OUTPUT

A job that needs 25 quarts requires 6 gallons plus 1 quarts.

Explanation:

This program is not designed to take any input from the user and hence, no validation is implemented.

1. A constant integer variable is declared to hold the number of quarts present in a gallon of paint.

const int QUARTS_IN_GALLON = 4;

2. An integer variable is declared to hold the quarts of paint needed for the job. This variable is initialized inside the program.

int quartsNeeded = 25;

3. Two integer variables are declared to hold the number of gallons and quarts calculated from the variables declared and initialized previously.

4. The number of gallons is computed as shown. Since gallon variable is an integer variable, it will store only the integer part of the result.

gallons = quartsNeeded/QUARTS_IN_GALLON;

If there is no remainder for the above expression, the variable quarts will be assigned 0. Hence, no validation is required for this.

5. The number of quarts is computed as shown. Since quarts variable is an integer variable, it will store only the integer part of the result.

quarts = quartsNeeded%QUARTS_IN_GALLON;

If there is no remainder for the above expression, the variable quarts will be assigned 0. Hence, no validation is required for this.

6. Lastly, display the message informing the number of gallons and quarts needed in all.

7. The program ends with a return statement.

You might be interested in
Of all excavation hazards, _______ poses the greatest risk
Phantasy [73]

Cave-ins

pose the greatest risk and are much more likely than other excavationrelated accidents to result in worker fatalities. Other potential hazards include falls, falling loads, hazardous atmospheres, and incidents involving mobile equipment.

7 0
3 years ago
A top-notch IT company is seeking an experienced leader to direct a team of experts in the development, creation, and modificati
Eduardwww [97]
Information Support and Services
8 0
3 years ago
Read 2 more answers
Question 2 (2 points)
bezimeni [28]

You can add a bookmark by clicking the star icon

<u>Explanation:</u>

Sometime you may have to visit a same page many times. It will be very difficult to search every time and go to the same page. It will be waste of time. Hence, there is an option available so that you can visit the page that you want to access many time without wasting your time.

In order to visit the page that you want to access more frequently you can use two ways. Most of the browsers will support to visit the most frequently accessed websites using the keyboard shortcuts Ctrl+D. You can also click on the star icon that is present in the address bar of the browser's top portion.

3 0
3 years ago
Need help with this, will give brainliest
Ganezh [65]
What is this? i’m not sure what i’m looking at
7 0
2 years ago
Favorite color should it be stored why?or why not?<br>​
Triss [41]

Answer:

Explanation:

green

8 0
3 years ago
Other questions:
  • What Is the output of the following: =OR (5 &lt;7, 16*Rand ()&gt;23,FALSE)
    5·1 answer
  • Consider the following class definitions. public class BClass { private int x; public void set(int a) { x = a; } public void pri
    11·1 answer
  • When Mark’s organization implemented an IS, they faced the lack of confidence in users. Which strategy can improve user confiden
    11·1 answer
  • What is the purpose of the domain name​
    5·1 answer
  • We have written a method called sum with an int[] parameter nums. We want our sum method to compute the sum of nums, but our cod
    5·1 answer
  • One lap around a standard high-school running track is exactly 0.25 miles. Write a program that takes a number of miles as input
    12·1 answer
  • Which of the following browsers was introduced with windows 10?
    10·1 answer
  • Write a program that inputs a five-digit integer, spearates the integer into its digits and prints them seperated by three space
    6·1 answer
  • How to solve household arithmetic​
    7·1 answer
  • Given three floating-point numbers x, y, and z, output x to the power of y, x to the power of (y to the power of z), the absolut
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!