For each of the following tasks, provide the complete pseudo code Task 1 (3 pts)
ID: 3748456 • Letter: F
Question
For each of the following tasks, provide the complete pseudo code
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.
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.)
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.
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…
Explanation / Answer
Task 1 :
_________________________________
scan(price)
sum = price
while(price != -1) // terminating condition
{
sum = sum + price
scan(price)
}
if(sum > 100)
shipping = 0
else
shipping = 2*sum/100
_________________________________
Task 2 :
Input from user : initial balance (P) & a monthly interest rate (R)
The formulae used is : A = P (1 + r/n) (nt)
Here n = 1; and r,p are user given... t varies from 1 to 12 months
Collective formulae becomes : A = P (1 + r) (t)
_________________________________
scan(P)
scan(R)
print(initial balance : P)
print(rate : R)
balance=P
for (t from 1 to 12)
balance = balance*(1+r)
print(balance after t months : balance)
end-for
_________________________________
Task 3 :
I am using "-1" as the sentinel value...
If the user enters -1 ---> the user wants to see the average of entered grades till now and exit the program
_________________________________
n=0
avg = 0
scan(grade)
while(grade != -1)
avg = ( grade + (n*avg) ) / (n+1)
n ++
scan(grade)
end-while
print(avg)
_________________________________
Task 4 :
_________________________________
print(Want to play the game?)
print(Enter Y/N)
scan(c)
while(c == Y)
print(Enter your choices : R or P or S for rock, paper, scissor respectively)
print(Player A, Enter your choice)
scan(A)
print(Player B, Enter your choice)
scan(B)
if(A == R)
{
if(B == P)
print(Paper beats rock: Player B wins)
else if (B == S)
print(Rock breaks Scissor : Player A wins)
else
print(Draw)
}
else if(A == P)
{
if(B == R)
print(Paper beats rock: Player A wins)
else if (B == S)
print(Scissors cut Paper : Player B wins)
else
print(Draw)
}
else
{
if(B == P)
print(Scissors cuts Paper: Player A wins)
else if (B == R)
print(Rock breaks Scissor : Player B wins)
else
print(Draw)
}
_________________________________
******************NOTE******************
If there is any doubt, please reply in the comments
If you need complete code also, reply in the comments
If everything is clear, please rate accordingly
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.