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
Instructions The population of town A is less than the population of town B. However, the population of town A is growing faster
weeeeeb [17]

Answer: The c++ program is given below.

#include <iostream>

using namespace std;

int main() {

float townA, townB, growthA, growthB, populationA, populationB;

    int year=0;    

cout<<"Enter present population of town A : ";

cin >> townA;  

cout<<endl<<"Enter present growth rate of town A : ";

cin >> growthA;

growthA = growthA/100;  

cout<<endl<<"Enter present population of town B : ";

cin >> townB;  

cout<<endl<<"Enter present growth rate of town B : ";

cin >> growthB;

growthB = growthB/100;  

do

{

    populationA = townA + (townA * growthA);

    populationB = townB + (townB * growthB);      

    townA = populationA;

    townB = populationB;      

    year++;      

}while(populationA < populationB);  

cout<<endl<<"After " <<year<< " years, population of town A is "<<populationA << " and population of town B is "<< population<<endl;

return 0;

}

Explanation:

All the variables for population and growth rate are declared with float datatype.

The user inputs the present population of both the towns.

The growth rate entered by the user is the percentage growth.

For example, town A has 10% growth rate as shown in the output image.

The program converts 10% into float as 10/100.

growthA = growthA/100;

growthB = growthB/100;

The above conversion is done to ease the calculations.

The year variable is declared as integer and initialized to 0.

The growth in population is computed in a do-while loop. After each growth is calculated, the year variable is incremented by 1.

The loop continues until population of town A becomes greater than or equal to population of town B as mentioned in the question.

Once the loop discontinues, the final populations of town A and town B and the years needed for this growth is displayed.

The new line is introduced using endl keyword.

The function main has return type int hence, 0 is returned at the end of the program.

6 0
3 years ago
Help!
aleksandrvk [35]

Answer:

it may be linear gradient.

6 0
1 year ago
In what Career Cluster you get to design, build, and destroy things
vaieri [72.5K]

Answer: Architecture

Explanation:

A career cluster can be defined as the group of careers in which professionals are related to common features or occupational tasks are related based on the common features. One person in a career cluster may like more than one job profiles in the same career cluster.

In architecture a person may like to design, build and destroy things to redesign them again. This involves knowledge, skills, mental and physical labor. Building and road constructions are the tasks performed by the architectures.

7 0
2 years ago
A furniture manufacturer wants to find a more environmentally friendly way to make its products. A data analyst helps solve this
Alecsey [184]
The answer has to be true because everything makes sense
4 0
2 years ago
A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To ac
Vikentia [17]

Answer:

input-year taken 2020

2020 is divisible by 2

output- 2020 is a leap year

3 0
2 years ago
Other questions:
  • Write a function shampoo_instructions() with parameter num_cycles. If num_cycles is less than 1, print "Too few.". If more than
    7·1 answer
  • What color does Sam obtain when he mixes white with a color? Sam is painting a landscape and needs to paint the sky light blue.
    9·2 answers
  • What does PowerPoint display when you use the Notes Page view?
    14·2 answers
  • Need help with just #8
    12·1 answer
  • 50 points for each person brainless goes to the best answer
    14·2 answers
  • In the SQL environment, a _____________ is a logical group of database objects – such as tables and indexes – that are related t
    11·1 answer
  • Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binar
    13·1 answer
  • Kevin is working in the Tasks folder of his Outlook account. Part of his computer screen is shown below.
    14·1 answer
  • Define a function isPrime that consumes an integer argument and returns 1 if it'a prime number; 0 if it's not a prime number.
    9·1 answer
  • Help me. thank you very much
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!