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
How can you troubleshoot Internet access problems?
joja [24]

Answer:

Check the network icon (or wireless connection settings) to see if you have Internet access. ...

Check for changes to proxy settings.

Check the network cables if your computer is wired to the router.

Reset your router.

Check your firewall or security software.

Hopefully this helps.

8 0
3 years ago
What is the command to disable any Processes in linix??
stiks02 [169]

Answer: killall[process_name]  or kill[PID]

Explanation:

Killall is a tool for disabling running processes on the system. It will disable all programs that matches the name mentioned.

kill disables processes based on process id numbers. it does not disable the process directly. The process recieves a signal where the process will follow instructions which it has to follow if it receives the signal.

7 0
2 years ago
Exodia<br>Principle of Computer Operation​
tamaranim1 [39]

Answer:

????

Explanation:

6 0
3 years ago
On a Linux system it is considered bad manners to create files and folders in the _______________ directory.
guapka [62]

Answer:

Root

Explanation:

Linux is an open source operating system which receives command from the user and communicates with the hardware, and in Linux the root directory is the top level directory that contains all other directory, it is not recommended to create files and folders in  the root directory because the commands the user enters may change files that the operation system may depend on for usage.

5 0
3 years ago
In PyCharm, write a program that prompts the user for their name and age. Your program should then tell the user the year they w
Neporo4naja [7]

Answer:

def main():

   name = input("What is your name? ")

   if not name == "" or "":

       age = int(input("What is your age? "))

       print("Hello " + name + "! You were born in " + str(2021 - age))

main()

Explanation:

Self explanatory

5 0
2 years ago
Other questions:
  • Janis is preparing a financial document. She needs to use the dollar symbol placed above the number key 4. Which key will Janis
    12·2 answers
  • What do you call the process of translating statements written by a developer? What is the result of this process?
    6·1 answer
  • PLEASE HELP!
    12·2 answers
  • Program should allow for user to enter students name and his four test scores it should calculate and display the average and le
    7·1 answer
  • What has information technology made piracy possible?
    14·1 answer
  • Given the code segment below, complete the assignments as stated in the comments. struct aaa { int m; int nn; } struct bbb{ stru
    13·1 answer
  • Just answer in five-line. Question:
    9·1 answer
  • On the classic gameshow The Price Is Right, contestants must guess the price of an object (guesses are distinct). The winner is
    5·1 answer
  • true or false You are able to change the formatting of a table after it is inserted into a placeholder.
    6·1 answer
  • assuming the default gateway is connected to the internet, what type of internet access would this server have?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!