Marshall_Ramsey Lab03.docx .docx

Both these loops are pre test loops which means that

Info icon This preview shows pages 3–5. Sign up to view the full content.

Both these loops are pre-test loops which means that if the first test fails (is false) then the statements in the loop body are never executed. The do while loop is also indefinite but is post test so that loop runs the code block at least once before the first test. Lab: 1. Just submit this document (See directions below.) and insert your work after each task description. 2. For each of the following tasks, provide the complete pseudo code including all elements that we have been using (i.e. class, end class, main return, output prompt). Be sure to declare your variables and use symbolic constants where appropriate. Determine if each task requires a definite or indefinite loop and use the correct one. I will likely do the first one in class with you. a. Task 1 (3 pts): an application program where the user enters the price of a series of items (assume at least one.) (Prompt user for additional items until they are done, so we don’t know ahead how many items there will be. This is the looping part! ;) ) The program computes shipping costs. If the total price of all items is $100 or more, then shipping is free otherwise it is 2% of the price. The program should output the total price of all items and the shipping cost. class shipping main() //declarations Num itemcost=0 Num totalcost=0 Num shippingcost=0
Image of page 3

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

Do Output “Enter item cost or N if you would like to quit…” Input itemCost if item cost => 100 output “Your shipping cost is free.” Else shippingCost = itemCost * 0.02 totalCost = itemCost + shippingCost output “Your shipping cost is “ + shippingCost + “ and your total cost is “ + totalCost + “.”
Image of page 4
Image of page 5
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