Question

In: Computer Science

3. Write a C++ program that takes in the name of a store, and the following...

3. Write a C++ program that takes in the name of a store, and the following details for 4 employees working at the store; their first name, last name, number of hours they worked that week and how much they are paid per hour. Your program should output the name of the store, along with each employee's full name and how much they earned that week in the manner below. Monetary values should be format to 2 decimal places. Also consider that a store could have as many words contained in it's name (Best Buy, Harris Tetter, The Home Depot)

Ballack's Electronic Store

Jon Snowden $452.50

Midoriya Izuku    $363.99

Thomas Muller $1322.00

Senku Ishigami $895.50

Use the different output formatting methods

Solutions

Expert Solution

Please find below code and don't forget to give a Like.

Please refer below code with explanation in comments and output.

Code:

#include <iostream>
#include<iomanip>
#include<math.h>

using namespace std;
float rounding(float value){
float var=(int)(value*100+.5);
return (float)var/100;
}

int main()
{   
//storing firstname and lastname in string array
string firstname[4]={"Jon","Midoriya","Thomas","Senku"};
string lastnamr[4]={"Snowden","Izuku","Muller","Ishigami"};
//stoing price per hour and hours worked in a week in float array
float price_perhour[4]={20,30,15.5,25.5};
float hours_worked[4]={50,60,45,35};
float total_price[4];
string store[1]={"Ballack's Electronic Store"};
//using for loop to run and calculate the total price of that employee
for(int i=0;i<=3;i++){
total_price[i]=price_perhour[i]*hours_worked[i];
}
cout<<store[0]<<endl;
for(int j=0;j<=3;j++){
//here calling rounding function to round of the decimal values to 2 places
cout<<firstname[j]<<" "<<lastnamr[j]<<" "<<rounding(total_price[j])<<endl;
}


return 0;
}

Output:


Related Solutions

Write a program in c# that declare a variable and store user name jjohn in. Then,...
Write a program in c# that declare a variable and store user name jjohn in. Then, write a statement that will make your program display at the screen the content of that variable, followed by " I would like to know your height in centimeter. Please enter it:". Then, write a statement that will store the value entered by the user, allowing decimal numbers ie some precision, a fraction part. Finally, write statements (more than one can be needed) so...
Write a program that does the following in C++ 1 ) Write the following store data...
Write a program that does the following in C++ 1 ) Write the following store data to a file (should be in main) DC Tourism Expenses 100.20 Revenue 200.50 Maryland Tourism Expenses 150.33 Revenue 210.33 Virginia Tourism Expenses 140.00 Revenue 230.00 2 ) Print the following heading: (should be in heading function) Store name | Profit [Note: use setw to make sure all your columns line up properly] 3 ) Read the store data for one store (should be in...
Write c code program for the following Write a function, circle, which takes the radius of...
Write c code program for the following Write a function, circle, which takes the radius of a circle from the main function and assign the area of the circle to the variable, area, and the perimeter of the circle to the variable, perimeter. Hint: The function should have three variables as input. Since the contents of the variables are to be modified by a function, it is necessary to use pointers. Please type out the full usable program. Thank you.
Write a C++ program to display toy name
Write a C++ program to display toy name
Tail of a File, C++ Program. write a program that asks the user for the name...
Tail of a File, C++ Program. write a program that asks the user for the name of a text file. The program should display the last 10 lines, or all lines if less than 10. The program should do this using seekg Here is what I have so far. #include<iostream> #include<fstream> #include<string> using namespace std; class File { private:    fstream file;    string name; public:    int countlines();    void printlines(); }; int File::countlines() {    int total =...
1. Write a program in C++ that takes as inputs a positiveinteger n and a...
1. Write a program in C++ that takes as inputs a positive integer n and a positive double a. The function should compute the geometric sum with base a up to the powern and stores the result as a protected variable. That is, the sum is: 1 + ? + ? ^2 + ? ^3 + ? ^4 + ⋯ + ? ^?2.  Write a program in C++ that takes as input a positive integer n and computes the following productsum...
Program in C Write a function that takes a string as an argument and removes the...
Program in C Write a function that takes a string as an argument and removes the spaces from the string.
Write a program in C or C++ that takes a number series of size n (n...
Write a program in C or C++ that takes a number series of size n (n integers) as input from the user, push all the numbers to the stack, and reverse the stack using recursion. Please note that this is not simply popping and printing the numbers, but the program should manipulate the stack to have the numbers stored in reverse order. In addition to the provided header file, the students can use the following function to print the content...
Write a Java program that uses printf, and takes user input to find the name of...
Write a Java program that uses printf, and takes user input to find the name of the File. FileCompare (20) Write a program that compares to files line by line, and counts the number of lines that are different. You can use file1.txt and file2.txt when testing your program, but you must ask for the file names in the input. main Interactively requests the names of the two files, after creating the Scanner for the keyboard. Creates a Scanner for...
write a c++ program using micro soft visual studio 2010 to write a program and store...
write a c++ program using micro soft visual studio 2010 to write a program and store 36 in variable x and 8 in variable y. add them and store the result in the variable sum. then display the sum on screen with descriptive text. calculate the square root of integer 36 in x. store the result in a variable. calculate the cube root of integer 8 in y. store result in a variable. display the results of square root and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT