EBK JAVA PROGRAMMING
8th Edition
ISBN: 9781305480537
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
expand_more
expand_more
format_list_bulleted
Question
error_outline
This textbook solution is under construction.
Students have asked these similar questions
Java
Your program will read in a credit card number and expiration date from the user and validate the data. The program will continue to ask for user input until a valid number and date are entered. The rules for what is valid are specified below.
readYear() and readMonth(int) methods
Complete the readYear() and readMonth(int) methods. These methods ask the user to input the expiration year and month of their credit card.
Each method should contain a loop inside the method so the code repeats until a valid month or year is entered by the user.
If the user enters an invalid year or month, print an error message and ask them to try again.
The readMonth(int) method reads in the month as a number. A valid month is any number between 1 and 12 (inclusive).
A valid year is 2022 or later.
readCreditCardNumber() method
Complete the readCreditCardNumber() method. This method asks the user to input their credit card number.
This method should contain a loop so the code repeats until a valid…
You will complete a class called Socks. It simulates loading a series of socks into a sock drawer..The class will have the following methods:• newsocks( ) : this method will receive a series of socks. Your code will ask the userhaw many pairs of socks are being added to drawer (because, after all, socks shouldALWAYS come in paris). Then use a loop to obtain the sock color. Users can enterblue, brown, black, or white for sock color. For any other color, they will receive amessage that the color is not allowed and to enter a proper color.o How many pairs of socks? (Answer: 3)o For sock #1, what color? (Answer: white)o For sock #2, what color? (Answer: blue)o For sock #3, what color? (Answer: green)o That is not a valid color. Try again. For sock #3, what color? (Answer: blackThis method will update the attribute to maintain the current and accurate count ofsocks.• list( ) : this method will print the number of sock pairs for each color, one color per line.For instance, the result might…
The local Driver’s License Office has asked you to write a program that grades the written
portion of the driver’s license exam. The exam has 20 multiple choice questions. Here are
the correct answers:
1. B 6. A 11. B 16. C
2. D 7. B 12. C 17. C
3. A 8. A 13. D 18. B
4. A 9. C 14. A 19. D
5. C 10. D 15. D 20. A
A student must correctly answer 15 of the 20 questions to pass the exam.
Write a class named DriverExam that holds the correct answers to the exam in an array field.
The class should also have an array field that holds the student’s answers. The class should
have the following methods:
• passed. Returns true if the student passed the exam, or false if the student failed.
• totalCorrect. Returns the total number of correctly answered questions.
• totalIncorrect. Returns the total number of incorrectly answered questions.
• questionsMissed. An int array containing the question numbers of the questions that
the student missed.
Demonstrate the class in a complete…
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- In java A Carpet Company has asked you to write an application that calculates the price of carpeting for rectangular rooms in a building. To calculate the price, you multiply the area of the floor (width * length) by the price per square foot of carpet. For example, the area of floor that is 12 feet long and 10 feet wide is 120 square feet. To cover that floor with carpet that costs 300 per square foot would cost (12 * 10 * 300 = 36000.) First, you should create a class named RoomDimension that has two attributes: one for the length of the room and one for the width. Provide getters/setters, parameterized constructor and a toString method. The RoomDimension class should also have a member function that returns the area of the room. Once you have written the class, use in a test application that asks the user to enter the number of rooms in building create array of that size, then ask user to enter dimensions for each room, also ask user for price per square foot of the desired…arrow_forwardWrite a program that generates a random number in the range of 1 through 100, and asks the user to guess what the number is. If the user's guess is higher than the random number, the program should display "Too high, try again." If the user's guess is lower than the random number, the program should display "Too low, try again." If the user guesses the number, the application should congratulate the user and generate a new random number so the game can start over. Additional Enhancement: Enhance the game so it keeps count of the number of guesses that the user makes. When the user correctly guesses the random number, the program should display the number of guesses.arrow_forwardthis assignment wants me to: Write an application that computes and displays the day on which you become(or became) 10,000 days old. For example, if you we're born on January 1st, 2000, the output would be I will be 10000 days old on 2027-05-19. It is giving me errors in the picture shown in here. here is my code: import java.time.*; import java.util.Scanner; public class TenThousandDaysOld { public static void main(String[] args) { Scanner in = new Scanner(System.in); int month; int day; int year; int daysOld = 10000; System.out.println("Enter month"); month = in.nextInt(); System.out.println("Enter day"); day = in.nextInt(); System.out.println("Enter year"); year = in.nextInt(); LocalDate birthDate = LocalDate.of(year, month, day); LocalDate futureDate = birthDate.plusDays(daysOld); System.out.println("I will be " + daysOld + " old on " + futureDate); } }arrow_forward
- *USING JAVA* Write a program that will use a while loop to print a table of the gross pay earned by an employee each hour over a specified period of time. Create a project named Chap4-GrossPay. Then create a class named GrossPay. Write code to create a program that will ask the user to enter the hourlyPayRate of an employee and save it to a variable. Next, ask the user to enter the totalHours the employee worked for the day and save it to a variable. Set a variable named hour=1, this variable will be used to control how many times your loop will spin. Next, code a while loop to print a table displaying each hour the employee worked and the gross cummulative pay earned by the employee. Use printf codes (not spaces) to align all your table data. Sample Output: Enter the hourly pay rate of the employee: 25.00 Enter the number of hours the employee worked today: 6 Here is a table of the gross pay earned per hour for this employee: Hour Gross Pay Earned 1 25.00 2 50.00 3…arrow_forwardI need a flowchart for this * RockNRollah.java * Write an application to simulate the rolling of two dice. * The application should use an object of class Random once * to roll the first die and again to roll the second die. * The sum of the two values should then be calculated. * Each die can show an integer value from 1 to 6, so the sum of the values will vary from 2 to 12, * with 7 being the most frequent sum, and 2 and 12 the least frequent. * Your application should roll the dice 36,000,000 times. * Use a one-dimensional array to tally the number of times each possible sum appears. * Display the results in tabular format.arrow_forwardThe Freemont Automobile Factory has discovered that the longer a worker has been on the job, the more parts the worker can produce. Write an application that computes and displays a worker’s anticipated output each month for 24 months assuming the worker starts by producing 4,000 parts and increases production by 6 percent each month. Also display the month in which production exceeds 7,000 parts (when the worker deserves a raise!) as follows: The month in which production exceeds 7000.0 is month X. This is what i have but isnt right public class IncreasedProduction { publicstaticvoidmain (String[] args) { // final int month = 24; double parts =4000.0; double production =0.06; double raise =7000.0; int counter; System.out.println("The month in which production exceeds 7000.0 is month " + month); counter = 1; while(counter >= parts) { System.out.print(counter + " "); counter = counter + 1; } System.out.println(); } }arrow_forward
- First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ==> Close All Projects).Then create a new Java application called "Scorer" (without the quotation marks) that declares a two-dimensional array of doubles (call it scores) with three rows and three columns and that uses methods and loops as follows.Use a method containing a nested while loop to get the nine (3 x 3) doubles from the user at the command line.Use a method containing a nested for loop to compute the average of the doubles in each row.Use a method to output these three row averages to the command line.arrow_forwardCreate an application that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows:1. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Do not display the computer’s choice yet.)2. The user selects his or her choice of rock, paper, or scissors. To get this input you can use Button controls, or clickable PictureBox controls displaying some of the artwork that you will find in the student sample files.3. The computer’s choice is displayed.4. A winner is selected according to the following rules:• If one player chooses rock and the other player chooses scissors, then rock wins. (Rock smashes scissors.)• If one player chooses scissors and the other player chooses paper, then scissors wins. (Scissors cuts paper.)• If one player chooses…arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
CPP Function Parameters | Returning Values from Functions | C++ Video Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=WqukJuBnLQU;License: Standard YouTube License, CC-BY