Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Instructions For each of the following 4 problems provide 1. inputs 2. outputs 3

ID: 3755193 • Letter: I

Question

Instructions For each of the following 4 problems provide 1. inputs 2. outputs 3. error conditions 4. an algorithm using pseudocode 5. the minimum and the maximum number of operations 6. a set of test cases 1. Multiplication Compute and display the result of how much a certain number of pounds of apple costs. 2. Gas Compute and display the price a person will pay for gas at the gas station. If the person pays with a credit card, there is an extra charge of 10% of the total price 3. University tuition Compute the tuition a student pays at an university, given the following rules: Every student pays a campus fee of $6.87 .Each one credit costs $20 An university employee pays only campus fee State employee pays campus fee + 10% of total number of credits cost Assume a student cannot be an university employee and a state employee at the same time A student paying in installments pays an additional 3% of total amount owed 4. Zoo census There are a number of zoos in the United States. Each of these zoos is a home to giraffes, lions and snakes. Determine and display the total number of each (giraffes, lions, and snakes) in the zoos in the United States. Assume positive values.

Explanation / Answer

Solution:

1)

input: number of pounds of apple to be bought, cost of the apple per pound

Output: Expense to be made to buy apples.

Error condition: number of pounds <0, price per pound < 0

Algorithm using pseudo-code:

Step 1 : Declare variables Ans = 'Y', no_of_pounds, price_per_pound, cost

Step2 : While ( Ans = 'Y')

Step2.1 : Read no_of_pounds,price_per_pound

Step2.2 : cost := no_of_pounds * price_per_pound

Step2.3 : Print cost

Step2.4 : Provide the option for continue (Y) or abort (N)

Step2.5 : Read ans

  

Step3: End.

The minimum number of operation : 1 (As, one will go to the loop at least once,beacuse the value of 'ans' is 'Y' by default.

Maximum operations: As many times as one wants. As many times the user will want to continue the loop will iterate.

Set of test cases:

1.

no_of_pounds = 2

price_per_pound = 4

2.

no_of_pounds = 6

price_per_pound = 4

2)

Input: Litre of gas to be bought, Price per liter, Payment type

Output: Payment to be made

Error Condition: Litre of gas to be bought<0, Price per liter <0

Pseudo-code:

Step1: Declare variables Litre of gas to be bought, Price per liter, ans, Cost, choice = 1

Step2: while (choice == 1)

Step2.1: Read Litre of gas to be bought,  Price per liter

Step 2.2: Print " Do you have the credit card, Press Y for yes and N for no

Step 2.3: Read ans

Step 2.4: if (ans = 'Y')

Step 2.4.1: cost =  Litre of gas to be bought * Price per liter * 1.1

Step 2.4.2: Print cost

Step2.5: if (ans = 'N')

Step 2.5.1: cost =  Litre of gas to be bought * Price per liter

Step 2.5.2: Print cost

Step 2.6: Print "Do you want to continue? if yes enter 1

Step 2.7: Read choice

Step 3: Exit

Minimum No of Operations: 1 ( As the value of option = 1)

Maximum No of Operations: As many as you want

Set of test cases:

1. Litre of gas to be bought = 2

Price per liter, Payment type = 20

2. Litre of gas to be bought = 3

Price per liter, Payment type = 10

3)

3. Pseudo code :

Then SET ES to “UE”

        Else if ES is State Employee

Then SET ES to “SE”

         Else

       Set ES to “NE”

Else if ES equals to SE then set FEE=(CF+10/100*CC)

Else set FEE=CF+CC

FEE=FEE+3/100*FEE

Else

FEE

       I .   Write FEE

4. Pseudo code :

Read no of giraffes in zoo(i) i.e. NG

Read no of lions in zoo(i) i.e. NL

Read no of giraffes in snakes (i) i.e. NS

Set TNG=TNG+NG

Set TNL=TNL+NL

Set TNS=TNS+NS

End loop

4. Write TNG , TNL,TNS

I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)