Access Millions of academic & study documents

Problem Sets in Programming Worksheet

Content type
User Generated
Subject
Programming
Type
Worksheet
Showing Page:
1/2
PROBLEM SETS IN PROGRAMMING - 2
1. (Converting Celsius to Fahrenheit) Write a program that reads a Celsius degree in double from the
console, then converts it to Fahrenheit and displays the result. The formula for the conversion is as
follows: fahrenheit = (9 / 5) * celsius + 32
Here is a sample run:
2. (Computing the volume of a cylinder) Write a program that reads in the radius and length of a cylinder
and computes volume using the following formulas:
area = radius * radius * volume = area * length
Here is a sample run:
3. (Financial application: calculating tips) Write a program that reads the subtotal and the gratuity rate,
then computes the gratuity and total. For example, if the user enters 10 for subtotal and 15% for gratuity
rate, the program displays PHP 1.5 as gratuity and PHP 11.5 as total.
Here is a sample run:
4. (Summing the digits in an integer) Write a program that reads an integer between 0 and 1000 and adds
all the digits in the integer. For example, if an integer is 932, the sum of all its digits is 14.
Hint: Use the % operator to extract digits, and use the / operator to remove the extracted digit. For
instance, 932 % 10 = 2 and 932 / 10 = 93.
Here is a sample run:
5. (Financial application: payroll) Write a program that reads the following information and prints a
payroll statement:
Employee’s name (e.g., Smith)
Number of hours worked in a week (e.g., 10)
Hourly pay rate (e.g., 6.75)
Federal tax withholding rate (e.g., 20%)
State tax withholding rate (e.g., 9%)

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/2

Sign up to view the full document!

lock_open Sign Up
Unformatted Attachment Preview
PROBLEM SETS IN PROGRAMMING - 2 1. (Converting Celsius to Fahrenheit) Write a program that reads a Celsius degree in double from the console, then converts it to Fahrenheit and displays the result. The formula for the conversion is as follows: fahrenheit = (9 / 5) * celsius + 32 Here is a sample run: 2. (Computing the volume of a cylinder) Write a program that reads in the radius and length of a cylinder and computes volume using the following formulas: area = radius * radius * volume = area * length Here is a sample run: 3. (Financial application: calculating tips) Write a program that re ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Studypool
4.7
Indeed
4.5
Sitejabber
4.4