replace number 2 with this: search through, if it has an x, find location of that x and print it out. if it doesnt have an x, print that without an error.
These will be due on Labor Day, Monday, September 4 at noon. Turn in all files to the shared google drive folder with your name on it. You can see a video version of the lesson on this topic here: https://www.youtube.com/watch?v=NaTmH34uwng and https://www.youtube.com/watch?v=S4frRRu5img
0. Please move/delete all of your old labs from your shared folder!! This folder is only intended to be for current work you are turning in.
1. Write a program (IfOddEven) that prompts the user to enter an integer, and then decides if it is odd or even (use %: what is the remainder if you divide an even number by 2? what if you divide an odd number by 2?) and prints that. Submit IfOddEven.java
2. Update last week’s StringStart program (copy paste your code then re-title your class IfStringStart) so that if the user enters a substring that is NOT in the whole string (like if I try searching for "math" in "computer science is awesome" – it will not be found), the program will print out a mean (but clean) message. If the substring is found, it should do the same thing as last week. Recall, as the quick reference guide says, that indexOf returns a -1 if the substring is not found. Submit IfStringStart.java
3. As activity director at Lake LazyDays Resort, it is your job to suggest appropriate activities to guests based on the weather. Write a program called IfLazyDays.java that asks the user for the temperature, then prints out the activity appropriate for that temperature. You will want to use several else if statements. Here are the recommendations for each temperature:
temp >= 90: swimming
60 <= temp < 90: golf (note that you cannot type this compound inequality in an if statement, you will have to get clever)
40 <= temp < 60: tennis
temp < 40: skiing
If the temperature is greater than 95 or less than 20, your program should also print "Visit our shops!" in addition to giving the activity.
Submit IfLazyDays.java
4. Create a payroll program (IfSalary.java) that will calculate your paycheck based on the numbers of hours worked and your hourly pay. The program should have the user type in their hourly wage, and the number of hours worked. If you work less than 40 hours, you will simply make your wage times your hours.
If you work between 40-60 hours, the first 40 hours will get paid at the normal wage, and then you make 1.5x your wage as overtime for the extra hours past 40 (so if you work 50 hours, you get paid for the first 40 at the regular rate, and the next 10 at the regular rate times 1.5). If you work more than 60 hours, you make 2x your wage in double overtime for the extra hours (past 60) in addition to the 1.5x for hours 40-60. Here are some examples:
For instance, if my wage is $10 an hour, and I worked 12 hours, I would earn:
Regular salary: 12*10
So my total paycheck for the week would be 120 bucks.
If my wage is $10 an hour, and I worked 45 hours, I would earn:
First 40 hours: 10*40 = 400
Hours 40-45: 10*1.5(overtime bonus)*5 hours = 75
So my total paycheck for the week would be 475 bucks.
If my wage is $10 an hour, and I worked 65 hours, I would earn:
First 40 hours: 10*40 = 400
Hours 40-60: 10*1.5(overtime bonus)*20 hours = 300
Hours 60+: 10*2 (double overtime bonus)*5 hours = 100
So my total paycheck for the week would be 800 bucks.
HINT: To help with the math, in each of the three cases, first break down how many hours were worked in each of the three categories. For example, if you worked more than 60 hours, how many hours did you work at the normal rate and how many did you make at overtime rate? Submit IfSalary.java.
5. Write a program called IfSort.java that will give the smallest and largest of three numbers the user types in. Have the user enter 3 floating point (double) numbers (in any order). Your program should then decide which one is the largest, which one is the smallest, and then print those out. If two of the three are equal, it should work correctly (for instance if the user types in 4,4,6.7, it should say the min is 4, max is 6.7). If all three of the numbers are equal, the program should insult the user. Submit IfSort.java.
6. Write a program called IfRPS.java - This program will let the user play rock paper scissors against a computer opponent. The user will type in a String, either “rock” “paper” or “scissors.” The program will then randomly decide which of the three options the computer opponent will choose (just have it pick a random number then use if statements to assign a String for the computer. As you test your code, make sure that the computer can pick all three!), print what the computer chose, and then decide (and print) who wins! Submit IfRPS.java
For 2 points of Extra Credit: Modify your RPS program to ask the user if they want to play again. If they say yes, have the game play again and keep track of the users win-loss-tie record. If they say no, the program should quit. (you will need to look up while loops to do this)