Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Name: B. Priyadharshini.

Batch: SVC-11
Assignment – 2.
Topic: Algorithm Selection.

1. Calculate purchase amount to be paid after discount. Consider 10 % discount


for the Sale amount above 1000. Formula: Purchase Amount = price *
quantity Discount Amount = Purchase amount * 0.10 Paid Amount =
Purchase Amount – Discount Amount

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:

Step 1: Start the Program.


Step 2: Get an integer value as number.
Step 3: check the number, if the number is Not divisible by 2 (number%2! =0) execute Step
3.1, if the number is Divisible by 2(number%2==0) execute Step 3.2 otherwise Execute Step
3.3.
Step 3.1: Show “You entered number is Odd”.
Step 3.2: Show “You Entered number is Even”.
Step 3.3: Show “Enter the Valid Number”.
Step 4: Show the proper output as odd or even number.
Step 5: Stop the Program.

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:

Step 1: Start the program.


Step 2: Input Total Shopping amount.
Step 3: Find Discount Percentage as
If Total_shoppingAmount is greater than or equal to
5000(Total_shoppingAmount>=5000) then execute 3.1 or Total_shippingAmount is
less than 1000 and equals to 4999((Total_shoppingAmount<1000) and
(Total_shoppingAmount ==4999)) then execute 3.2 or Total_shoppingAmount is less
than 1000(Total_shoppingAmount<1000) then execute Step 3.3.

Step 3.1:Show “Discount Percentage is 25”.


Step 3.2: Show “Discount Percentage is 10”.
Step 3.3: Show “Discount Percentage is 5”.
Step 4: Calculate Discount amount as
Discount amount=(Total_shoppingAmount*Discount Percentage)/100
Step 5: Calculate Final amount as
Final amount=Total_shoppingAmount – Discount amount.
Step 6: Print Final Amount.
Step 7: Stop the program

You might also like