Absolute Java (6th Edition)
6th Edition
ISBN: 9780134041674
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 1, Problem 36STE
Write a line of Java code that will give the name ANSWER to the int value 42. In other words, make answer a named constant for 42.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Can you write a new code in Java language with the values I sent you, just like this output?
There are two files named group1.txt and group2.txt that contain course information and grades of each student for each class. I will calculate each course average for each group and show in simple bar graph. Use "*" and "#"characters for group1 and group2, respectively. I will see the number -999 at the end of each line in the input files. This value is used for line termination and you can use it to verify that you have arrived at the end of the line. The averages of each group should also be calculated and printed at the end of the file.
Group 1:
CSC 80 100 70 80 72 90 89 100 83 70 90 73 85 90 -999
ENG 80 90 80 94 90 74 78 63 83 80 90 -999
HIS 90 70 80 70 90 50 89 83 90 68 90 60 80 -999
MTH 74 80 75 89 90 73 90 82 74 90 84 100 90 79 -999
PHY 100 83 93 80 63 78 88 89 75 -999
Group 2:
CSC 90 75 90 75 80 89 100 60 80 70 80 -999
ENG 80 80 70 68 70 78 80 90 90 76 -999
HIS 100 80 80 70 90 76 88…
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…
Java - Musical Note Frequencies
Chapter 1 Solutions
Absolute Java (6th Edition)
Ch. 1 - If the following statement were used in a Java...Ch. 1 - Give a statement or statements that can be used in...Ch. 1 - Write a complete Java program that uses to output...Ch. 1 - What is a compiler?Ch. 1 - What is a source program?Ch. 1 - What is an object program?Ch. 1 - What do you call a program that runs Java...Ch. 1 - Suppose you define a class named NiceClass in a...Ch. 1 - Prob. 9STECh. 1 - Prob. 10STE
Ch. 1 - Can a Java program have two different variables...Ch. 1 - Give the declaration for two variables called feet...Ch. 1 - Give the declaration for two variables called...Ch. 1 - Prob. 14STECh. 1 - Prob. 15STECh. 1 - Prob. 16STECh. 1 - Convert each of the following mathematical...Ch. 1 - What is the output of the following program...Ch. 1 - What is the output produced by the following lines...Ch. 1 - Prob. 20STECh. 1 - Given the following fragment that purports to...Ch. 1 - What is the output produced by the following lines...Ch. 1 - What is the output produced by the following lines...Ch. 1 - What is the output produced by the following?
Ch. 1 - What is the output produced by the following?...Ch. 1 - What is the output produced by the following?...Ch. 1 - What is the output produced by the following?
Ch. 1 - Prob. 28STECh. 1 - Prob. 29STECh. 1 - What is the output of the following two lines of...Ch. 1 - Suppose sam is an object of a class named Person...Ch. 1 - The following code is supposed to output the...Ch. 1 - Prob. 33STECh. 1 - What is the output produced by the following Java...Ch. 1 - What is the normal spelling convention for named...Ch. 1 - Write a line of Java code that will give the name...Ch. 1 - Body Mass Index (BMI) helps in specifying the...Ch. 1 - The video game machines at your local arcade...Ch. 1 - Write a program that starts with the string...Ch. 1 - A government research lab has concluded that an...Ch. 1 - Write a program that starts with a line of text...Ch. 1 - Write a program for calculating the simple...Ch. 1 - Write a program that outputs the number of hours,...Ch. 1 - The following program will compile and run, but it...Ch. 1 - A simple rule to estimate your ideal body weight...Ch. 1 - Scientists estimate that roughly 10 grams of...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
In the chapter, we introduced a machine instruction of the form ODROS. Suppose we extended this form to OxDRXS,...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
The solid steel shaft AC has a diameter of 25 mm and is supported by smooth bearings at D and E. It is coupled ...
Mechanics of Materials (10th Edition)
A(n) ___________ constructor is one that requires no arguments.
Starting Out with C++ from Control Structures to Objects (9th Edition)
(Greatest Common Divisor) The greatest common divisor (GCD) of two integers is the largest integer that evenly ...
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Rock, Paper, Scissors Game Write a program that lets the user play the game of Rock, Paper, Scissors against th...
Starting Out with Python (4th Edition)
2-1 List the five types of measurements that form the
basis of traditional ptane surveying-
Elementary Surveying: An Introduction To Geomatics (15th Edition)
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 pleasearrow_forwardyou are asked to test the log10 function (double log10(double a)) in Java Math library. You do not have the source code for the function however the specifications of the function are available. The specifications of the function as follows: Function returns the base 10 logarithm of the given double value. If the argument is equal to 10n for integer n, then the result is n. If the argument is NaN or less than zero, then the result is NaN. If the argument is positive infinity, then the result is positive infinity. If the argument is positive zero or negative zero, then the result is negative infinity. *NaN is a numeric data type value which stands for “not a number” (e.g. Double.NaN) 1. Explain why performing exhaustive testing (testing with all possible inputs) on this method might not be considered efficient testing and propose an efficient testing strategy. 2. Explain how the proposed testing strategy is performed and list the minimum amount of test inputs required to…arrow_forwardwrite an application that reads English-Language phrase and encodes it into morse code. also write an application that reads a phrase in morse code and converts it into the English-Language equivalent . Use one blank between each Morse-code letter and three blanks between each Morse-coded word.arrow_forward
- Write a Java program for the given problem using Array. Toyota Company wants to create an application to calculate the overtime payment for its Engineers. The program should read the number of Engineers. The program will accept the Engineer ID, Engineer name, Salary and Overtime Working days of all Engineers. If Overtime Working days is greater than or equal to 25, Overtime payment is calculated as 25% of Salary, else if Overtime Working days is greater than or equal to 10 and less than 25, Overtime payment is calculated as 15% of Salary, otherwise Overtime payment is calculated as 10% of Salary. Compute the Total salary by adding the Salary and Overtime payment. Display Engineer ID, Engineer name, Salary, Overtime payment and Total salary of all the Engineers.arrow_forwardI need help to write this code in JAVA with comment please Write a program that stores the total amount of rain for each month in an array. Prompt the user for the values for each month to load the array. Display this information back to them in a nice format with the name of the month and the rainfall for that month. Display back the total rainfall for the year, the average monthly rainfall, the month with the most rain, the month with the least rain, the months with rainfall above average, and the months with rainfall below average. Do not accept negative numbers from the user to be stored in the array.arrow_forwardPart 2 - OddOrEven ClassIn bluej. Write a program that prompts the user to enter an integer. The program should display “The input is odd" to the screen if the input is odd and displays “The input is even" to the screen if the input is even. Hint: Consider using the mod (%) operator.arrow_forward
- JAVA Change the calendar printing program so it starts the week on a Sunday. Also make it print a newline at the end (but only one). The code itself would display the calendar and you would not have to use the println function as you would have to do that for every single month and year. The program would grab the month a year you selected and display it. How change this code? import java.time.DayOfWeek;import java.time.LocalDate;import java.time.Month; public class Calendar { public static void main(String arg []) { int month = 5;LocalDate date= LocalDate.of(year, month, 1);while (date.getMonthValue() == month) { System.out.println(date.getDayOfMonth()); date = date.plusDays(1); }} }arrow_forwardjavaarrow_forwarduse javaarrow_forward
- For Java Write code for an if-else block that checks separates integers into the following categories: An integer less than 0, An integer greater than 0 and less than or equal to 10, An integer greater than 10 that is even, and an integer greater than 10 that is odd. Have each category print out a different statement. What are some ways you can make your code more efficient when using if-else blocks?arrow_forwardIn Java (Use the isPrime Method) PrimeNumberMethod.java, provides the isPrime(int number) method for testing whether the number is prime. Use this method to find the number of prime numbers less than 10000. Below are some clarifications for the Java program (a) The lab is to COUNT the prime numbers less than 10000. Do NOT list the prime numbers. (b) A pair prime is two prime numbers whose difference is 2. For e.g. 3,5; 11,13; 17, 19; etc. We can use IsPrime function to count how many pair primes are there in a range from 2 to 100 for example. Create a function pairPrime, that takes one argument. pairPrime should return the number of pair primes between 2 and the argument passed. Use the pairPrime function to count the pair primes between 2 and 1000. Make use of the IsPrime function to solve this task. (This feature is worth 8 points). Use the compile/run button to test tour program. Include the output displayed. It will be similar to: command>javac…arrow_forwardProblem: Write a Java program that will prompt for and read one word entered by the user, and generate its reverse, then create a new word which contains the first letter of the word, the first letter of the reverse word, followed by the second character of the word, followed by the second character of the reverse word, and so on, as pictured in the figure below: word Gábriel ĞlaebirribealG new word reverse word leirbag You can use the loop of your choice to solve the problem. You are not allowed to use arrays. Be sure to use the same format and wording as in the sample run in the table below. You can use the loop of your choice to solve the problem. Based on the previous specifications your program should behave and look exactly as shown in the cases below. Your program should work for any word entered by the user, not just the ones in the samples. Note that in the output • symbol is a space and e is a new line character. All words except for user input (in green) must be exactly as…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
The Top Down Approach to Software Development; Author: Christopher Kalodikis;https://www.youtube.com/watch?v=v9M8LA2uM48;License: Standard YouTube License, CC-BY