You are on page 1of 1

1.

Write a program that computes and displays a 15 percent tip when the price of a meal is input by the
user. (Hint: the tip is computed by multiplying the price of the meal by 0.15.) You will need the
following variables:

1. //declare variables
2. Declare MealPrice As Float
3. Declare Tip As Float
4. //Ask for user input
5. Write “Enter the price of the meal: ”
6. Input MealPrice
7. //compute the Tip
8. Set Tip = 0.15*MealPrice
9. //display the result
10.Write “The amount of your tip is: ”+Tip

2. Write a program that converts a temperature input in degrees Celsius into degrees Fahrenheit and
displays both temperatures. You will need the following variables:

1. //declare variables
2. Declare Celsius As Float
3. Declare Fahrenheit As Float
4. //Ask for user input
5. Write “Enter temperature in Celsius: ”
6. Input Celsius
7. //compute temperature in kelvin
8. Set Fahrenheit= (9/5)*Celsius+32
9. //display the result
10.Write “Temperature Celsius to kelvin is: ”+Fahrenheit

3. Write a program that computes and displays the batting average for a baseball player when the user
inputs the number of hits and at-bats for that player. Batting average is computed by dividing the
number of hits by the number of at-bats. You will need the following variables:

1. //declare variables
2. Declare Hits, AtBats As Integer
3. Declare BatAvg As Float
4. //Ask for user input
5. Write “Enter the number of hits for the player: ”
6. Input Hits
7. Write “Enter the number of at-bats for the player: ”
8. Input AtBats
9. //compute the batting average for the player
10.Set BatAvg = (Hits/AtBats)
11.//display the result
12.Write “The batting average of the player is: ”+BatAvg

You might also like