Assignment 2
Assignment 2
Batch: SVC-11
Assignment – 2.
Topic: Algorithm Selection.
Solution:
Step 1: Start the Program.
Step 2: Initialize Price amount.
Step 3: Getting the Value for Purchase Amount as
Purchase Amount = Price *Quantity.
Step 4: If the Purchase amount is more than 1000 then execute Step 4.1 otherwise execute
Step 4.2.
Step 4.1: Providing Discount For one who purchase more than 1000 as
Discount amount = Purchase amount* 0.10
Then,
Step 4.1.1: Paid Amount will be Calculated as
Paid Amount= Purchase amount – Discount amount.
Step 4.1.2: Show output with Discounted Amount
Step 4.2: Show that “You are not eligible to get Discount Amount”.
Step 5: Stop the Execution.
2. Identify whether the given number is Positive or Negative Sample I/O: Enter
any number = 9 Enter any number = -8 9 is positive -8 is negative
Solution:
Step 1: Start the Program.
Step 2: Get an integer value as number.
Step 3: check the number, if the number is less than 0(number<0) execute Step 3.1, if the
number is greater than 0(number>0) execute Step 3.2 otherwise Execute Step 3.3.
Step 3.1: Show “You entered number is negative”.
Step 3.2: Show “You Entered number is positive”.
Step 3.3: Show “Enter the Valid Number”.
Step 4: Show the proper output as positive or negative number.
Step 5: Stop the Program.
3. Find whether the given number is Odd or Even Sample I/O: Enter any
number = 7 Enter any number = 6 7 is Odd Number 6 is Even Number
Solution:
4. Identify whether the given number is smallest among three numbers Sample
I/O: N1=8 N2=6 N3=9 N2 is smallest number
Solution:
Step 1: Start the Program
Step 2: Initialize Values as N1, N2 and N3.
Step 3: If ((N1<N2 )and(N1<N3)) then execute Step 3.1 or ((N2<N3) and (N2<N1)) execute Step
3.2 or ((N3<N2) and (N3<N1)) execute Step 3.3 otherwise execute Step 3.4.
Step 3.1: Show “N1 is a Smallest number”.
Step 3.2: Show “N2 is a Smallest number”.
Step 3.3: Show “N3 is a Smallest number”.
Step 3.4: Show “Invalid”.
Step 4: Show Appropriate output according to those rules.
Step 5: Stop.
5. Read total shopping amount purchased in the shop, and then apply the
discount as per the following discount criteria, then find and print the final
amount that has to be paid by the customer after subtracting the discount
amount: Shopping Amount Discount% 5000 and Above 25% 1000 - 4999
10% Below 1000 5%
Solution: