Lesson 6 Control Statements Continued: Logical Operators
Password.java
- Write a program called Password.java that prompts the user for a four-character password, accepts four characters, and then outputs the characters to the screen. Print source code and output before moving to next problem
- Modify your password.java program so that if the user enters a B, a message that the password is valid will appear; otherwise a message that the password is not valid will appear. Print source code and output before moving to next problem.
- Modify your password.java program so that if the characters entered spell BOLT, then output a message that the password is valid; otherwise, the password is invalid. Print source code and output.
furniture.java
- Write a program for a furniture company. Save the program as Furniture.java. Ask the user to choose ‘P’ for pine, ‘O’ for oak, or ‘M’ for mahogany. Show the price of a table manufactured with the chosen wood. Pine tables cost $100, oak tables cost $225, and mahogany tables cost $310. Test your program. Copy source code and output. Print
- Add a prompt to your furniture.java program to ask the user to specify a large (L) or a small (S) table. Add $35 to the price of any large table. Save the program as FurnitureSizes.java. Copy source code and output. Print
Admissions.java
- Write an Admissions.java program for a college’s admissions office. Create variables to store a student’s numeric high school GPA (example 3.5) and an admission test score. Print the message “Accept” if the student has any of the following:
- GPA of 3.0 or higher and an admission test score of at least 60
- GPA below 3.0 and an admission test score of at least 80
If the student does not meet either of the qualifications, print “Reject.”
******************************************************************************
Challenge problem on back…….
Calculate.java
- Write a program that stores two integers and allows the user to enter a character. If the character is ‘A’, add the two integers. If it is ‘S’, subtract the second integer from the first; if it is ‘M’, multiply the integers. Display the results of the arithmetic. Print source code and output.
Calculate2.java
- Modify the Calculate.java program so the user can also enter a D for divide. If the second number is zero, then display an error message; otherwise divide the first number by the second number and display the results. Print source code and output.