Basic Java programming HELP!
Hi I'm new to Java and I have this assignment I have to complete.
1) How do I use a "for loop" statement to write a program that stores the sum of the first 10 positive integers, 1+ 2 + 3 + ... + 8 + 9 + 10 in an int variable, and displays the total as the sum progresses? i.e. 1,3,6,10, .....
2) I have to write a program that prompts the user for an integer number. The program should determine whether or not the number is even, and then inform the user of its conclusion.
Aaand write the program so that the program will continuously prompt the user to input a number until the user has successfully provided an even number.
3) I have to write a program where the computer knows a random number between 1 and 100 and the user is the guesser. At the end of the game, the computer displays the number of guesses required by the user to guess the number correctly.
4) An employee's total weekly pay equals the hourly wage multiplied by the total number of regular hours for that week plus any overtime pay. Overtime pay equals the total overtime hours multiplied by 1.5 times the hourly wage. Write a program that takes as inputs the hourly wage, total regular hours for the week, and total overtime hours for the week, and displays an employee's total weekly pay for that week.
Can anyone help me with at least 1 of the programs?
Thank you
Re: Basic Java programming HELP!
Re: Basic Java programming HELP!
Quote:
Originally Posted by
Javreg
Hi I'm new to Java and I have this assignment I have to complete.
1) How do I use a "for loop" statement to write a program that stores the sum of the first 10 positive integers, 1+ 2 + 3 + ... + 8 + 9 + 10 in an int variable, and displays the total as the sum progresses? i.e. 1,3,6,10, .....
2) I have to write a program that prompts the user for an integer number. The program should determine whether or not the number is even, and then inform the user of its conclusion.
Aaand write the program so that the program will continuously prompt the user to input a number until the user has successfully provided an even number.
3) I have to write a program where the computer knows a random number between 1 and 100 and the user is the guesser. At the end of the game, the computer displays the number of guesses required by the user to guess the number correctly.
4) An employee's total weekly pay equals the hourly wage multiplied by the total number of regular hours for that week plus any overtime pay. Overtime pay equals the total overtime hours multiplied by 1.5 times the hourly wage. Write a program that takes as inputs the hourly wage, total regular hours for the week, and total overtime hours for the week, and displays an employee's total weekly pay for that week.
Can anyone help me with at least 1 of the programs?
Thank you
Sure, we can help, but first you must ask an answerable question or two. So far, all I see is an exact listing of your assignment and no discernible question. Certainly no one is going to do any of these for you (and if they do, us moderators will be sure to delete the answer immediately), but without a specific question, about all we can do is direct you to the tutorials.
So please come on back, show your work including your current code surrounded by [code] [/code] tags, and some answerable questions and we'll be glad to help.