Write a VB.Net program that allows a taxi company to calculate how much a taxi fare should be - AQA - GCSE Computer Science - Question 5 - 2021 - Paper 1
Question 5
Write a VB.Net program that allows a taxi company to calculate how much a taxi fare should be.
The program should:
- allow the user to enter the journey distance i... show full transcript
Worked Solution & Example Answer:Write a VB.Net program that allows a taxi company to calculate how much a taxi fare should be - AQA - GCSE Computer Science - Question 5 - 2021 - Paper 1
Step 1
Allow the user to enter the journey distance in kilometres
96%
114 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Dim distance As Double
Console.WriteLine("Enter the journey distance in kilometres:")
distance = Convert.ToDouble(Console.ReadLine())
Step 2
Allow the user to enter the number of passengers
99%
104 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Dim passengers As Integer
Console.WriteLine("Enter the number of passengers:")
passengers = Convert.ToInt32(Console.ReadLine())
Step 3
Calculate the taxi fare by charging £2 for every passenger
96%
101 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Dim fare As Double
fare = 2 * passengers
Step 4
Charging a further £1.50 for each kilometre
98%
120 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
fare += 1.5 * distance
Step 5
Output the final taxi fare
97%
117 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Console.WriteLine("The final taxi fare is: £" & fare)