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
laila [671]
3 years ago
12

Walmart store wants to compare the sales of five of its stores. Write a complete program to ask the user to enter the sales for

5 stores. Create a bar chart displaying stars representing the sale amount for the day. must follow the requirements main method calls the print method. a for loop is required print method accepts an integer as its parameter representing the sale for the day. display stars based on the sale. one star represents $100 sale. a for loop is required Sample output:

Computers and Technology
1 answer:
marysya [2.9K]3 years ago
8 0

Answer:

Here is the C++ program.

#include <iostream>  //to use input output functions

using namespace std;   //to identify objects cin cout

   void print(int sales){   //method that accepts integer as its parameter representing the sale for the day

          for(int i=0;i<(sales/100);i++){  //loop to create a bar chart

           cout<<"*";   }   }  //prints stars representing the sale amount for the day

   int main(){          

       int sales1;    // stores the sales of store 1

       int sales2;    // stores the sales of store 2

       int sales3;    // stores the sales of store 3

       int sales4;     // stores the sales of store 4

       int sales5;    // stores the sales for store  5    

       

       cout<<"Enter the sales for store 1: ";  //prompts user to enter sales for store 1

       cin >>sales1;  //reads the value of sales for store 1 and stores it in sales1

       print(sales1);  //calls print method to display start representing the sales amount for the day for store 1

       cout<<"\nEnter the sales for store 2: ";  //prompts user to enter sales for store 2

     cin >>sales2;  //reads the value of sales for store 2 and stores it in sales2

       print(sales2); //calls print method to display start representing the sales amount for the day for store 2

       cout<<"\nEnter the sales for store 3: ";  //prompts user to enter sales for store 3

     cin >>sales3;  //reads the value of sales for store 3 and stores it in sales3

       print(sales3);  //calls print method to display start representing the sales amount for the day for store 3

       cout<<"\nEnter the sales for store 4: ";  //prompts user to enter sales for store 4

     cin >>sales4;  //reads the value of sales for store 4 and stores it in sales4

       print(sales4);  //calls print method to display start representing the sales amount for the day for store 4

       cout<<"\nEnter the sales for store 5: ";  //prompts user to enter sales for store 5

     cin >>sales5;  //reads the value of sales for store 5 and stores it in sales5

       print(sales5);     } //calls print method to display start representing the sales amount for the day for store 5

Explanation:

The program is well explained in the comments attached with each line of the program. Lets say user enters 100 as sales for store 1. Then the for loop works as follows:

for(int i=0;i<(sales/100);i++)

At first iteration:

i = 0

i<(sales/100) is true because 0 is less than 100/100 = 1

so the program moves to the body of loop which has the statement:

cout<<"*"

This prints one asterisk one output screen. Next the loop breaks when i = 1. So this only prints one asterisk in output since one star represents $100 sale. The screenshot of the program along with its output is attached.

You might be interested in
To analyze data from a survey, you use a spreadsheet to calculate the percent of students who prefer corn over broccoli or carro
alisha [4.7K]

<u>Answer</u>:

<em>By changing the decimal to a percentage </em>

<u>Explanation:</u>

Since the requirement is to calculate the percentage of students about their preference in eating vegetables, we need to convert the given values to percentage only.  

<em> Option A: </em>By changing the addition sign to a multiplication sign. This is invalid because, there is no addition and multiplication involved in converting to percentage

<em>Option C:</em> By changing the percentage to a decimal. The given data is not available in percentage so conversion is impossible.

<em>Option D:</em> By changing the multiplication sign to a division sign Multiplication and division are not going to be performed here, since we need only percentage.

4 0
3 years ago
Read 2 more answers
Free Write Friday 2/26/21
Bad White [126]
Write about art bc thags always so cool
4 0
3 years ago
Write a C++ programthat simulates a cash register. The user should keeptyping
-Dominant- [34]

Answer:

//C++ code for the cash register..

#include <iostream>

#include<vector> //including vector library

using namespace std;

int main() {

vector<float> cash; //declaring a vector of type float.

float item=2,cash_sum=0;

int counter=1;

while(item!=0)//inserting prices in the vector until user enters 0...

{

    cout<<"Enter the price of item "<<counter<<" :"<<endl;

cin>>item;

counter++;

cash.push_back(item);//inserting element in the vector...

}

for(int i=0;i<cash.size();i++)//looping over the vector...

{

    cash_sum+=cash[i];//summing each element..

}

cash_sum*=1.08;//adding 8% sales tax.

cout<<cash_sum;//printing the result....

return 0;

}

Explanation:

I have taken a vector of type float.

Inserting the price of each item in the vector until user enters 0.

Iterating over the vector for performing the sum operation.

Then after that adding 8% sales tax to the sum.

Printing the output at last.

6 0
3 years ago
What is a Database, Flat file and Relational Database?
Marta_Voda [28]

Answer:

A flat file database stores data in a single table structure. A relational database uses multiple table structures, cross-referencing records between tables. Tables in both organize records in rows, with each column containing a single piece of data in the record.

8 0
2 years ago
Sukhi needs to insert a container into her form to collect a particular type of information.
Hunter-Best [27]

Answer:

text box

Explanation:

on edge 2020

6 0
4 years ago
Other questions:
  • "A Windows laptop is being used by a teacher in an outdoor (but protected by an overhang) setting. What setting would ensure tha
    5·1 answer
  • A cyberbully is someone who invades another person’s privacy by
    13·2 answers
  • 3k means about 3 thousand bytes. how would you express two hundred million bytes? .
    8·1 answer
  • Henry is designing a document for his architecture project. In which order should Henry preform the different tasks that are req
    7·1 answer
  • In a stream channel what is deposited first?
    7·1 answer
  • Which entity might hire a Computer Systems Analyst to help it catch criminals?
    12·2 answers
  • 1. Which sentence best expresses the main idea
    12·1 answer
  • 2.11 (Separating the Digits in an Integer) Write a script that inputs a five-digit integer from the user. Separate the number in
    12·1 answer
  • So has anyone opened the link/file those people are giving out as answers? Like what are they, viruses, answers, nothing??? Some
    9·2 answers
  • What is the size of the rc.conf file in bytes
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!