Concept explainers
Write a
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Absolute Java (6th Edition)
Additional Engineering Textbook Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Problem Solving with C++ (10th Edition)
Starting Out with Python (4th Edition)
Database Concepts (8th Edition)
- In this assignment you will write a program that shows the valid moves of chess pieces. Your program will draw a board with 64 squares using the traditional layout, next ask the user to choose a move, and then, depending on the user's choice, redraw the board with the selected chess piece and its valid moves. Please see the examples of valid moves of chess pieces and the traditional chess board layout below:arrow_forwardTransient PopulationPopulations are affected by the birth and death rate, as well as the number of people who move in and out each year. The birth rate is the percentage increase of the population due to births and the death rate is the percentage decrease of the population due to deaths. Write a program that displays the size of a population for any number of years. The program should ask for the following data: The starting size of a population P The annual birth rate (as a percentage of the population expressed as a fraction in decimal form)B The annual death rate (as a percentage of the population expressed as a fraction in decimal form)D The average annual number of people who have arrived A The average annual number of people who have moved away M The number of years to display nYears Write a function that calculates the size of the population after a year. To calculate the new population after one year, this function should use the formulaN = P + BP - DP + A - Mwhere N is the…arrow_forwardThe Café Noir Coffee Shop wants some market research on its customers. When a customer places an order, a clerk asks for the customer’s zip code and age. The clerk enters that data as well as the number of items the customer orders. The program operates continuously until the clerk enters a 0 for zip code at the end of the day. When the clerk enters an invalid zip code (more than 5 digits) or an invalid age (defined as less than 10 or more than 110), the program reprompts the clerk continuously. When the clerk enters fewer than 1 or more than 12 items, the program reprompts the clerk two more times. If the clerk enters a high value on the third attempt, the program accepts the high value, but if the clerk enters a negative value onthe third attempt, an error message is displayed and the order is not counted. At the end of the program, display a count of the number of items ordered by customers from the same zip code as the coffee shop (54984), and a count from other zip codes. Also…arrow_forward
- Write a program that helps a company manage salaries of its employees. Your program should ask for the number of hours worked and the hourly rate of an employee than, display the salary. This program should allow the user to enter the information of many employees until enters -1. Sample Run: Enter the number of hours worked (-1 to end): 32 Enter hourly rate of the worker: 100 Balary is 03200 Enter the number of hours Worked (-1 to end) : 40 Enter hourly rate of the worker: 5 Balary is 3200 Enter the number of hours worked (-1 to end): 42 Enter hourly rate of the worker: 10 Salary is 0420 Enter the number of hours worked (-1 to end) : -1arrow_forwardGirl Scout Troop 815 has 18 members. Write a program in which the troop leader can enter the number of boxes of cookies sold by each scout, and output the total number of boxes sold and the mean and median values.arrow_forward10-6. Addition: One common problem when prompting for numerical input occurs when people provide text instead of numbers. When you try to convert the input to an int, you’ll get a ValueError. Write a program that prompts for two numbers. Add them together and print the result. Catch the ValueError if either input value is not a number, and print a friendly error message. Test your program by entering two numbers and then by entering some text instead of a number. 10-7. Addition Calculator: Wrap your code from 10-6 in a while loop so the user can continue entering numbers even if they make a mistake and enter text instead of a number.arrow_forward
- Please im using Program netbeansarrow_forwardC LANGUAGEarrow_forwardWrite a program that generates a plate number based on the user's answer to the following questions: 1. What is your favorite color of the rainbow (ROYGVIB)? a. Use the first letter of the chosen color as the first character of the plate number. b. Display "Invalid Input" and ask the user to re-enter his/her answer if the answer is not a valid color of the rainbow. 2. What is your month of birth? a. Use the last letter of the month as the second character of the plate number. b. Display "Invalid Input" and ask the user to re-enter his/her answer if the answer is not a valid month. 3. What is your first name? a. Use the third letter of the first name as the third character of the plate number. No need to include the second name if you have a second name. Make sure to use "cout" and "cin" to collect the necessary inputs from the user. For the number section: 1. Ask the user his/her age and use the age as the first and second digits of the plate number. a. Display "Invalid Input" and ask…arrow_forward
- TASK " Write a program that grades students' exam. The exam has 20 multiple choice questions. Here are the correct answers: 1- A 6- B 11-C 16- D 2- A 7- B 12- C 17- D 3- А 8- В 13-С 18- D 4- А 9- В 14- С 19- D 5- A 10-B 15- C 20- D "A student must correctly answer 15 of the 20 questions to pass the exam. " Write a class named StudentExam that holds the correct answers to the exam in an array. TASK (CONT.) " The class should also have an array that holds the student's answers. The class also should have the following methods: I passed. Returns true if the student passed the exam, or false if the student failed " totalCorrect. Returns the total number of correctly answered questions I totallncorrect. Returns the total number of incorrectly answered questions " questionsMissed. An int array containing the question numbers of the questions that the student missed. 1 On another class, ask the student to enter his name, take his answers and display the results returned from the StudentExam…arrow_forwardJava 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…arrow_forwardQuestions 1. Write a program which asks the user to enter a six-digit number and print a new number by subtracting 1 to each of its digits. For example, if the number entered is 393201, the output should be displayed as 282190. Information on the console should be displayed similar to the Sample Run shown below. Sample Run: Enter a 6 digit number: 393201 Modified number is: 28219darrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning