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

Java Problem

The document contains instructions for 3 programming problems that involve getting user input and displaying output. Problem 1 has the user input 3 numbers and displays the sum and average. Problem 2 gets length and width of a rectangle and displays the area and perimeter. Problem 3 gets the radius of a circle and displays the area and circumference. It also contains 2 looping problems, one calculating investment returns over years and another simulating coin tosses and displaying percentages.

Uploaded by

Marvin Marquez
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Java Problem

The document contains instructions for 3 programming problems that involve getting user input and displaying output. Problem 1 has the user input 3 numbers and displays the sum and average. Problem 2 gets length and width of a rectangle and displays the area and perimeter. Problem 3 gets the radius of a circle and displays the area and circumference. It also contains 2 looping problems, one calculating investment returns over years and another simulating coin tosses and displaying percentages.

Uploaded by

Marvin Marquez
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 17

Activity 1(Problem #1)

Create a program that will ask the user to input three number and be able to display the sum and average of

the three numbers

Sample Output
Enter first number: 3 Enter second number: 4 Enter third number: 7 Sum : 14 Average: 4.66

Activity 1(Problem #2)


Create a program that will ask the user to input length and width of the rectangle. Display the area and perimeter of the

rectangle

Sample Output
Enter the length: 7 Enter the width: 5 Area: 35 Perimeter: 24

Activity 1(Problem #3)


Create a program

that will ask the user to input a radius of the circle and be able to display the area and circumference of the circle

Sample Output
Enter the radius: 5

Circumference: 31.4 Area: 78.5

Loopin

g Activity
Problem #1
Write an

application that calculates the amount of money earned on an investment, based on an 8% annual return. Prompt the user to enter an investment amount and the number of years for the investment.

Modify the Investmen t application

in so the user also enters the interest rate. In

addition to the error message that displays

when the investmen t or term is 0, display an error

message if the interest rate is 0.


Sample Output

Give a value for principal 1000 Give a value for year 5 Give a value for rate 10 Payable Amount: 1610.51

Problem #2
Write an application

that displays the results of a series of 10 coin tosses. After each coin toss, display whether the toss represents heads or tails. After the 10 tosses are complete, display the percentages of heads and tails.

Modify the application in Exercise 9a so that you generate 1000 coin tosses and keep track of the heads and tails. Do not display the coin toss result with each flip, but instead display percentages of the heads and tails

after the 1000 coin tosses are complete.


Sample Output

Head: 513 Tail: 487 Head Percent: 51.30 Tail Percent: 48.70

You might also like