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
Who was eqvtime tayaishvili?​
maks197457 [2]

Answer:

Image result for who was eqvtime takaishvili?​

Ekvtime Takaishvili (also spelled Taqaishvili) (Georgian: ექვთიმე თაყაიშვილი) (January 3, 1863 – February 21, 1953) was a Georgian historian, archaeologist and public benefactor was born January 3, 1863 in Likhauri  and died February 21, 1953

3 0
3 years ago
Read 2 more answers
What is a biometric scanner?
Lisa [10]
<span>an electronic device used to determine a person's identity by detecting and matching the person's physical features, such as fingerprints or the eyes, to a database</span>
3 0
3 years ago
Read 2 more answers
Um i'm new here... and i don't know really how to use this... i was wondering if som 1 can help me
blagie [28]

Shining and warm

Collapse 3

JOJO

fate series

Bungou Stray Dog

EVA

Dao Master

Alien invasion

Future diary

Fate of Space

Story Series

Beyond the Boundary

Bayonetta

Onmyoji

Full-time master

How to develop a passerby heroine

Illusion Front

Psychometer

your name

Noragami

One Piece

Senran Kagura

Attacking Giant

Kabaneri of the Iron Fortress

Violet Evergarden

Demon Slayer

Under one person

Guilt crown

Black reef

Star Cowboy

Black Street Duo

Aria the Scarlet Ammo

Hatsune Miku

The last summoner

re creator

Detective Conan

Naruto

grim Reaper

Tokyo Ghoul

Song of Hell

At the beginning

Sword Art Online

Girl opera

Hakata pork bones pulled dough

Sunny

Black bullet

Trembling

On the broken projectile

Black Butler

Destiny's Gate

Persona

God Prison Tower

April is your lie

Ground-bound boy Hanako-kun

League of legends

Clever girl will not get hurt

Tomorrow's Ark

DARLING in the FRANKXX

RWBY

Little Busters

dating competition

Gintama

One Punch Man

The promised neverland

Taboo curse

God of college

Queen of Arms

Sword Net 3

Final fantasy

6 0
2 years ago
Read 2 more answers
1 There are several applications to assist you to surf through the internet, mention
prohojiy [21]
Email
Web browsing
Peer-to-peer services
3 0
3 years ago
circular_prime A number is called a circular prime if all rotations of its digits form a prime. For example, the number 197 is a
Lilit [14]

Answer:

function out=circular_primes(no)

prim=primes(no);% find the all prime number till the given number

pr=0;

nos=[];

po=[];

for p=1:length(prim)

   n=prim(p); % picking up each prime no one by one

   n=num2str(n);% change into string for rotation of no

   d=length(n); % length of string

   if d>1          % take nos greater than 10 beacuase below 10 no need for rotation

       for h=1:d

           a=n(1);

           for r=1:d % for rotation right to left

               if r==d  5 % for the last element of string

                   n(d)=a;

               else

               n(r)=n(r+1); %shifting

               end

           end

           

       s=str2num(n); % string to number

       nos=[nos,s]; % store rotated elements in array

       end

       if nos(end)==no   %if given no is also a circular prime we need smaller

           break;

       end

       for gr=1:length(nos) % checking rotated nos are prime or not

           p1=isprime(nos(gr));

           po=[po,p1];    %storing logical result in array

       end

           if sum(po(:))==length(nos) %if all are prime the length and sum are must be equal

               

               pr=pr+1;

               out=pr;

           else

               out=pr;

           end

       po=[];

       nos=[];

   else  

       s=str2num(n); %numbers less than 10

       f=isprime(s);

       if f==1

           pr=pr+1;

           out=pr;

       else

           out=pr;

       end

   end

       

      end

end

Explanation:

3 0
2 years ago
Other questions:
  • What is tuple and attribute of a relation​
    11·1 answer
  • Which function can you use to abbreviate the lengthy expression, A1+A2+A3+A3...+A19+A20?  MAX COUNT SUM ROUND
    10·2 answers
  • Which of the following should you always wear to avoid being thrown from a vehicle and then crushed if it tips over?
    12·2 answers
  • Your health insurance company gives you a discount if you wear a fitness-tracking bracelet. After wearing it for a few months, y
    5·1 answer
  • Your friend’s parents are worried about going over their budget for the month. Which expense would you suggest is NOT a need?
    10·2 answers
  • Which tab is used to configure editing restrictions in Word 2016? Review References Security Developer
    6·2 answers
  • It’s been six months since the disk crash at CSM Tech Publishing, and the owner is breathing a little easier because you install
    7·1 answer
  • Lin wants to play an online game with her friends. She read the description of the game and knows it contains several features w
    12·1 answer
  • Research and build a chroot jail that isolates ssh users who belong to the restrictssh group. (You will also need to create the
    9·1 answer
  • Using the Impress program, you can add multimedia files, including audio, image, and video files, to the presentation
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!