Question

cpp Description The purpose of this challenge is to use the for loops. This challenge uses...

cpp

Description

The purpose of this challenge is to use the for loops. This challenge uses accumulators and loops.

Requirements

  1. Assume you were offered a job that paid $0.01 on the first day, $0.02 the 2nd day, $0.04 the 3rd day (each day’s income is double the previous day’s income)
  2. Display what you made on each day
  3. Calculate and show how much you made in 30 days of work

DO NOT USE

Any power or exponentiation formulas

Sample Interaction / Output

On day 1, you made $0.01
On day 2, you made $0.02
...
On day 30, you made $5368709.12
After 30 days, you made $10737418.23

The last line above shows the total amount earned having worked 30 days. Make sure your total shows the amount above, not a penny more, not a penny less.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Source code and input output screenshots will be uploaded

Code:

#include <iostream>

using namespace std;

int main() {

double sal=0.01;

int days=1;

double total=0.01;

for(int I=1;I<=30;I++){

cout<<"on day"<<days<<",you made $";

cout<<std::fixed;

cout<<sal<< std::endl;

days=days+1;

sal=sal*2;

total=total+sal;

}

cout<<"after that days,you made $";

//To subtract the 31 day salary I have subtracted //once before printing

cout<<total-sal<<std::endl;

return 0;

}

Output:

on day1,you made $0.010000
on day2,you made $0.020000
on day3,you made $0.040000
on day4,you made $0.080000
on day5,you made $0.160000
on day6,you made $0.320000
on day7,you made $0.640000
on day8,you made $1.280000
on day9,you made $2.560000
on day10,you made $5.120000
on day11,you made $10.240000
on day12,you made $20.480000
on day13,you made $40.960000
on day14,you made $81.920000
on day15,you made $163.840000
on day16,you made $327.680000
on day17,you made $655.360000
on day18,you made $1310.720000
on day19,you made $2621.440000
on day20,you made $5242.880000
on day21,you made $10485.760000
on day22,you made $20971.520000
on day23,you made $41943.040000
on day24,you made $83886.080000
on day25,you made $167772.160000
on day26,you made $335544.320000
on day27,you made $671088.640000
on day28,you made $1342177.280000
on day29,you made $2684354.560000
on day30,you made $5368709.120000
after that days,you made $10737418.230000

screenshot

Add a comment
Know the answer?
Add Answer to:
cpp Description The purpose of this challenge is to use the for loops. This challenge uses...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Show Me The Money. (15 points) Write a C++ program that calculates how much a person...

    Show Me The Money. (15 points) Write a C++ program that calculates how much a person earns in a month if the salary is one penny the first day, two pennies the second day, four pennies the third day, and so on, with the daily pay doubling each day the employee works. The program should ask the user for the number of days the employee worked during the month and should display a table showing how much the salary was...

  • Use T-accounts to record the 4 months’ of transactions noted below for this new start-up company....

    Use T-accounts to record the 4 months’ of transactions noted below for this new start-up company. Record all entries affecting the income statement into “Equity” since there are no separate T-accounts set up for the individual income statement accounts. Once all transactions have been posted, populate the net ending balance for each account for the accounts listed below. Month 1 $2,000,000 sale of stock occurs with all cash received by the company. $3,000,000 bank loan received from the company’s bank...

  • A Pavlovian conditioning procedure known as Conditioned Place Proforence (CPP) is used to behaviorally measure the...

    A Pavlovian conditioning procedure known as Conditioned Place Proforence (CPP) is used to behaviorally measure the motivational effects of various stimuli or environmental conditions and is used as an animal model for human behaviors such as addiction. Using this paradigm, a researcher may assess the rewarding or punishing qualities of various substances To achieve this, a rodent is placed in one side of an open two-sided chamber for a certain period of time and is exposed to an Unconditioned Stimulus...

  • Month 1: $2,000,000 sale of stock occurs with all cash received by the company. $3,000,000 bank...

    Month 1: $2,000,000 sale of stock occurs with all cash received by the company. $3,000,000 bank loan received from the company’s bank at the end of the month – interest will start accruing next month (interest rate is 1% per month).  Principal and interest cash payments will be made in a lump-sum payment at the end of the loan period. Factory is leased at the beginning of the month and prepaid for the entire year up-front at a cost of $720,000.  The...

  • Account T-Account Record

    Month 1:$2,000,000 sale of stock occurs with all cash received by the company.$3,000,000 bank loan received from the company’s bank at the end of the month – interest will start accruing next month (interest rate is 1% per month).  Principal and interest cash payments will be made in a lump-sum payment at the end of the loan period.Factory is leased at the beginning of the month and prepaid for the entire year up-front at a cost of $720,000.  The first month of lease expense is expensed to the...

  • Month 1: $2,000,000 sale of stock occurs with all cash received by the company. $3,000,000 bank...

    Month 1: $2,000,000 sale of stock occurs with all cash received by the company. $3,000,000 bank loan received from the company’s bank at the end of the month – interest will start accruing next month (interest rate is 1% per month).  Principal and interest cash payments will be made in a lump-sum payment at the end of the loan period. Factory is leased at the beginning of the month and prepaid for the entire year up-front at a cost of $720,000.  The...

  • SOLVE USING C!!! Project objective: Conditional statements, loops, reading from file, user defined functions. **Submit source...

    SOLVE USING C!!! Project objective: Conditional statements, loops, reading from file, user defined functions. **Submit source code (LargeProg1.c) through Canvas One source code file(unformatted text) will be submitted Here is INCOMPLETE code to get started: LargeProg1.c The file name must match the assignment The code should be tested and run on a Microsoft compiler before it is uploaded onto Canvas The code must be submitted on time in order to receive credit (11:59PM on the due date) Late submissions will...

  • Question 7 Simpson Ltd. (Simpson) imports novelty items from Asian manufacturers and sells them to retailers....

    Question 7 Simpson Ltd. (Simpson) imports novelty items from Asian manufacturers and sells them to retailers. The company began operations at the beginning of 2018. The following information is available about Simpson's operation: • Simpson's suppliers allow it 30 days to pay for purchases. Assume purchases are made evenly throughout the year. Simpson allows customers 60 days to pay for their purchases. Assume sales occur evenly throughout the year. • Simpson has a markup on its product of 100 percent....

  • Write a Python program that calculate and summarize the sales of every day and finds out...

    Write a Python program that calculate and summarize the sales of every day and finds out who are the best employee who made more profits. For simplicity: We assume that the program works for only two days and for only two employees. i.e. the program collects and summarize the sales of only two days for only two employees The program accepts undefined number of sales for each employee. For example: You could assume in the first day the first employee...

  • You are the accountant for London Imports and Exports. The company imports and exports food and...

    You are the accountant for London Imports and Exports. The company imports and exports food and candy items throughout the world. The company is finalizing its 3rd quarter financial results. All adjustments have been made for the 3rd quarter except the adjustment for Bad Debts Expense. The preliminary 3rd quarter results along with the 1st and 2nd quarter results are shown below. London Imports and Exports Quarterly Income Statements (amounts in thousands of U.S. dollars) Q3 (preliminary) Q2 (as reported)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT