Generate the correct algorithm for the given scenario National Highways Department announces a scheme for four wheeler in toll gate for 50th year celebration. If the vehicle number is divisible by both 7 and 3 that will move on for free of cost. if the vehicle number id divisible by 7 or 3 then they should pay half of the fee. Otherwise You have to pay.
Answers
Answered by
12
Explanation:
National Highways Department announces a scheme for four wheeler in toll gate for 50th year celebration. If the vehicle number is divisible by both 7 and 3 that will move on for free of cost. if the vehicle number id divisible by 7 or 3 then they should pay half of the fee. Otherwise You have to pay.
Answered by
0
The algorithm for the given scenario is as follows:
- get the vehicle number
- store the vehicle number in the number data type.
- use two nested if statements to check the divisibility by 7 and by 3
- if the vehicle number satisfies the divisibility check, display " congratulations!! you are eligible to move free of cost"
- on the else part of the two nested if statements, check the divisibility for the other number using another if statement, if it satisfies the check, display " Congratulations!! you got 50% off on toll fee."
- in the else part of the nested ifs used on the 2nd part, write code to display "Oops! you have to pay the full toll fee."
sample code using python:
please refer to the attached screenshot:
#SPJ2
Attachments:
Similar questions