arial5black

1. sum of Numbers

write a program that asks the user for a positive nonzero integer value. the program should use a loop to get the sum of all integers from 1 up to number entered. for example, if the user enter 50, the loop will find the sum of 1,2,3,4,......50.

pls help me to generate some javacode here:

2. Distance Travel

the distance a vehicle can be calculated as follows:

Distance = Speed * Time

for example if the train travels a 40 miles per hour for the 3 hours, the distance taveled is 120 miles.

Design a class that stores the speed of vehicle and the number of hours it has traveled it should have a method named getdistance that returns the distance, in miles that the vehicle traveled.

Demonstrate the class in a program that uses loop to display the distance vehicle has travled for each hour of period specified by the user. for example, if a vehicle is traveling at 40Mph for a three hour time period, it should display a report similar to the one shown here:

Hour Distance traveled

1 40

2 80

3 120

input validationo not accept a negative number for speed and any values less than one for time traveled.

3. Pennies for Pay

write a prog. that calculates how much a person would earn over a period of time if his or her salary is one penny the first day, two pennies, the second day and continues to double each day. the prog. should display a table showing the salary for each day and then show the total pay at the end of this period. the output should be displayed in a dollar amoun, not in pennies number.

input validationo not accept a number less than one for the number of days worked.

4. Average Rainfall

write a prog. that uses nested loops to collect data and calculate the average rainfall over a period of years. the program should ask for the numbers of years. the outer loop will iterate once for each year. the inner loop will iterate twelve times, once for each month. each iterations of the inner loop will ask the user for the inches of rainfall for that month.

after all iterations, the prog. should display the number of months, the total inches of rainfall and average rainfall per month for the entire period.

5. THe Greatest and the Least of These:

write a prog. with loop that user enter a series of integers. the user should enter -99 to signal the end of the series. After all the numbers have been entered, the prog. should display the largest and smallest entered.

.........i hope some can help me to generate a basic java code or maybe applet if possible. i'll be looking forward to your consideration thank you!!

Hints: Use methods and Swing Commands