0% found this document useful (0 votes)
120 views

Problem Solving Assignment 1

The document provides code snippets for 3 programs: 1) A program to calculate a 15% tip based on a meal price input by the user. 2) A program to convert a temperature from Celsius to Fahrenheit based on a temperature input in Celsius. 3) A program to calculate the batting average of a baseball player based on inputs for number of hits and at-bats.

Uploaded by

prabh kaur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
120 views

Problem Solving Assignment 1

The document provides code snippets for 3 programs: 1) A program to calculate a 15% tip based on a meal price input by the user. 2) A program to convert a temperature from Celsius to Fahrenheit based on a temperature input in Celsius. 3) A program to calculate the batting average of a baseball player based on inputs for number of hits and at-bats.

Uploaded by

prabh kaur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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