Marshall_Ramsey Lab03.docx .docx

Return endclass b task 2 4 pts a program that prompts

Info icon This preview shows pages 4–6. Sign up to view the full content.

output “Your shipping cost is “ + shippingCost + “ and your total cost is “ + totalCost + “.” Return Endclass b. Task 2 (4 pts): A program that prompts the user for an initial balance and a monthly interest rate and then displays the new monthly balance for a 12 month period. (Interest is compounded.) class interest main() num bal num interest num month output “What is the balance?” input bal output “What is the monthly interest?” input interest for count = 1 to 12 step 1 bal = bal + (bal *interest) month = month + 1 ouput “The monthly balance is “ + bal + “for month” +month end for return end class c. Task 3 (3 pts): A program that collects a series of grades (ranging 0 – 100) until the user indicates that they don’t want to continue entering values. (Either use a sentinel value or prompt the user to continue each time.) The program should display the average of the grades entered. Class average Main() Num grade num allgrade
Image of page 4

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

num amount string finish output “What is the grade?” input grade allgrade = grade +allgrade amount = amount +1 output “Is that all the grades?” input finish while finish = no grade = allgrade / amount output “ The average grade is “ + grade return end class d. Task 4 (5 pts): Rock Paper Scissors: The game repeats as long as the user enters Y to a prompt to continue. Get a move from player A and then from player B. Assume that the move is valid so it has to be one of the 3 choices (R P or S). Your program should compute the winner with an appropriate output string: “Rock Breaks Scissors Player A wins. And then prompt to play again… Class rock Main() String pb String pa String r String p String s Output “Enter Player A’s move- R, P, or S.” “And enter Player B’s move- R, P, or S.”
Image of page 5
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.
  • Fall '17
  • Tom Wulf

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern