Ask Experts Questions for FREE Help !
Ask
    ladijock's Avatar
    ladijock Posts: 1, Reputation: 1
    New Member
     
    #1

    Dec 14, 2009, 03:11 PM
    QBasic help

    How about this one.. can anyone help?

    How about this one?

    You agree to work for a certain employer, but ask to be paid in a peculiar way. After the first day you are paid one penny. On each sucsessive day your pay is doubled. Write a program that determines your pay after 30 days. Your program should display your pay for each day of the 30 day period and the total pay earned after each day.

    Sample Display:

    Day Daily Pay Total Pay

    1 0.01 0.01
    2 0.02 0.03
    3 0.04 0.07
    Perito's Avatar
    Perito Posts: 3,139, Reputation: 150
    Ultra Member
     
    #2

    Dec 14, 2009, 08:09 PM
    Quote Originally Posted by ladijock View Post
    How about this one..can anyone help?

    How about this one?

    You agree to work for a certain employer, but ask to be payed in a peculiar way. After the first day you are paid one penny. On each sucsessive day your pay is doubled. Write a program that determines your pay after 30 days. Your program should display your pay for each day of the 30 day period and the total pay earned after each day.

    Sample Display:

    Day Daily Pay Total Pay

    1 0.01 0.01
    2 0.02 0.03
    3 0.04 0.07
    I'm not sure this is the proper place to put your question. It's really a mathematics question, not a programming one.

    Nonetheless, the first day your pay is 0.01. The second day, 0.02, the third day 0.04. In general, the day's pay is



    where n is the day number. Note that

    So, you perform the summation



    On a computer, in any basic language, this is totally trivial

    Dim sum As Double
    Dim onedays_pay As Double
    Dim i As Integer
    sum = 0

    For i = 1 To 30
    onedays_pay = 0.01 * 2 ^ (i - 1)
    sum = sum + onedays_pay
    Print "On day " & CStr(i) & " the payment is " & CStr(onedays_pay) & ", and the total so far is " & CStr(sum)
    Next i

    Print "The total pay is: " & sum

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Qbasic programming player's stats [ 5 Answers ]

Generate a report using the provided data file. The file contains hitting statistics for baseball players from a few seasons ago. The report will consist of batters' name, total times at bat, total hits, and final batting average. Computations are as follows: 1. total at bats = plate appearances -...

Another qbasic programming, student IDs and GPAs [ 1 Answers ]

Generate a report using the provided data file. The report will consist of student IDs and GPAs sorted by classes. Also within each class the students should ordered by GPA from largest to smallest (descending order). After each class list should be a line indicating the class average GPA. Input...

Qbasic programing [ 4 Answers ]

Please help me I have no idea how to program this thing! Develop a program using loops that displays rows of asterisks in two different ways: 1. Ascending then Descending * ** *** ****

QBASIC programming [ 1 Answers ]

Tell me how to do programming in qbasic

Running QBasic in Suse 10 (Linux) [ 11 Answers ]

Background: I have this QBasic program, consisting of these 3 files (QBASIC.EXE, QBASIC.HLP, QBASIC.INI), and it’s currently running on Windows XP SP2 OS. I plan to switch an entire lab to SUSE 10 Linux OS. I have a beginning programming class (senior high) that’s learning this old language. ...


View more questions Search