Big Java Late Objects
2nd Edition
ISBN: 9781119330455
Author: Horstmann
Publisher: WILEY
expand_more
expand_more
format_list_bulleted
Question
Chapter 5, Problem 10PP
Program Plan Intro
Java program to determine the grade of a student
Program plan
- Inside the “main” class,
- Declare the variables.
- Declare the scanner class and then get the user input.
- Execute “for” loop and then print the statement.
- Execute “if” condition and print the grades.
- Otherwise execute “else if” condition.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Can you implement the Student class using the concepts of encapsulation? A solution is placed in the "solution" section to help you, but we would suggest you try to solve it on your own first.
You are given a Student class in the editor. Your task is to add two fields:
● String name
● String rollNumber
and provide getter/setters for these fields:
● getName
● setName
● getRollNumber ● setRollNumber
Implement this class according to the rules of encapsulation.
Input #
Checking all fields and getters/setters
Output #
Expecting perfectly defined fields and getter/setters.
There is no need to add constructors in this class.
Note that you can only use recursion to solve Q1 and you cannot use any loop. You are free to add helper methods, but you are not allowed to change the method header.Question 1: Crazy seriesIn this session, you need to implement the crazy series method. In the crazy series, you will be given a starting number. Then, you need to times 2 for each number until the number is greater than 100. After the number is greater than 100, you need to divide 3 until we reach the number is less than 5. Note that the input number must be greater than 0, and you are not allowed to use loop here.For example,crazySeries(10) should return ArrayList [10.0, 20.0, 40.0, 80.0, 160.0, 53.333333333333336, 17.77777777777778, 5.9259259259259265, 1.9753086419753088]crazySeries(5) should return ArrayList [5.0, 10.0, 20.0, 40.0, 80.0, 160.0, 53.333333333333336, 17.77777777777778, 5.9259259259259265, 1.9753086419753088]crazySeries(1) should return ArrayList [1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0,…
Complete the java program. Use two methods and make one of them recursive
Chapter 5 Solutions
Big Java Late Objects
Ch. 5.1 - Consider the method call Math.pow(3, 2). What are...Ch. 5.1 - What is the return value of the method call...Ch. 5.1 - The Math.ceil method in the Java standard library...Ch. 5.1 - It is possible to determine the answer to Self...Ch. 5.2 - What is the value of cubeVolume(3)?Ch. 5.2 - Prob. 6SCCh. 5.2 - Provide an alternate implementation of the body of...Ch. 5.2 - Declare a method squareArea that computes the area...Ch. 5.2 - Consider this method: public static int...Ch. 5.3 - What does this program print? Use a diagram like...
Ch. 5.3 - Prob. 11SCCh. 5.3 - What does this program print? Use a diagram like...Ch. 5.4 - Prob. 13SCCh. 5.4 - What does this method do? public static boolean...Ch. 5.4 - Implement the mystery method of Self Check 14 with...Ch. 5.5 - How do you generate the following printout, using...Ch. 5.5 - Prob. 17SCCh. 5.5 - Prob. 18SCCh. 5.5 - Prob. 19SCCh. 5.5 - The boxString method contains the code for...Ch. 5.6 - Consider the following statements: int...Ch. 5.6 - Consider this method that prints a page number on...Ch. 5.6 - Consider the following method that computes...Ch. 5.6 - The comment explains what the following loop does....Ch. 5.6 - In Self Check 24, you were asked to implement a...Ch. 5.7 - Explain how you can improve the intName method so...Ch. 5.7 - Prob. 27SCCh. 5.7 - What happens when you call intName(0)? How can you...Ch. 5.7 - Trace the method call intName(72), as described in...Ch. 5.7 - Prob. 30SCCh. 5.8 - Which lines are in the scope of the variable i...Ch. 5.8 - Which lines are in the scope of the parameter...Ch. 5.8 - The program declares two local variables with the...Ch. 5.8 - There is a scope error in the mystery method. How...Ch. 5.8 - Prob. 35SCCh. 5.9 - Consider this slight modification of the...Ch. 5.9 - Consider this recursive method: public static int...Ch. 5.9 - Consider this recursive method: public static int...Ch. 5.9 - Prob. 39SCCh. 5.9 - The intName method in Section 5.7 accepted...Ch. 5 - In which sequence are the lines of the Cubes.java...Ch. 5 - Write method headers for methods with the...Ch. 5 - Give examples of the following methods from the...Ch. 5 - Prob. 4RECh. 5 - Consider these methods: public static double...Ch. 5 - Prob. 6RECh. 5 - Design a method that prints a floating-point...Ch. 5 - Write pseudocode for a method that translates a...Ch. 5 - Describe the scope error in the following program...Ch. 5 - For each of the variables in the following...Ch. 5 - Prob. 11RECh. 5 - Perform a walkthrough of the intName method with...Ch. 5 - Consider the following method: public static int...Ch. 5 - Consider the following method that is intended to...Ch. 5 - Suppose an ancient civilization had constructed...Ch. 5 - Give pseudocode for a recursive method for...Ch. 5 - Give pseudocode for a recursive method that sorts...Ch. 5 - Write the following methods and provide a program...Ch. 5 - Write the following methods and provide a program...Ch. 5 - Prob. 4PECh. 5 - Prob. 5PECh. 5 - Prob. 6PECh. 5 - Prob. 7PECh. 5 - Prob. 8PECh. 5 - Write methods public static double...Ch. 5 - Write a recursive method public static String...Ch. 5 - Write a recursive method public static boolean...Ch. 5 - Use recursion to implement a method public static...Ch. 5 - Use recursion to determine the number of digits in...Ch. 5 - Write a method that computes the balance of a bank...Ch. 5 - Write a method that tests whether a file name...Ch. 5 - It is a well-known phenomenon that most people are...Ch. 5 - Prob. 3PPCh. 5 - Use recursion to compute an, where n is a positive...Ch. 5 - Leap years. Write a method public static boolean...Ch. 5 - In Exercise P3.13 you were asked to write a...Ch. 5 - Prob. 10PPCh. 5 - Write a program that reads two strings containing...Ch. 5 - Prob. 12PPCh. 5 - Write a program that reads words and arranges them...Ch. 5 - Prob. 14PPCh. 5 - Write a program that reads two fractions, adds...Ch. 5 - Write a program that prints the decimal expansion...Ch. 5 - Write a program that reads a decimal expansion...Ch. 5 - Write two methods public static void...Ch. 5 - Write a program that reads in the width and height...Ch. 5 - Repeat Exercise P5.19 with hexagonal circle...Ch. 5 - Postal bar codes. For faster sorting of letters,...Ch. 5 - Write a program that reads in a bar code (with :...Ch. 5 - Write a program that converts a Roman number such...Ch. 5 - A non-governmental organization needs a program to...Ch. 5 - Having a secure password is a very important...Ch. 5 - Prob. 30PPCh. 5 - Prob. 31PPCh. 5 - Electric wire, like that in the photo, is a...Ch. 5 - The drag force on a car is given by FD=12v2ACD...
Knowledge Booster
Similar questions
- Create a class with a method. The method has to decide whether a given year is a leap year or not. Note- A year is a leap year if: • It has an extra day i.e. 366 instead of 365. It occurs in every 4 year e.g. 2008, 2012 are leap years. For every 100 years a special rule applies-1900 is not a leap year but 2000 is a leap year. In those cases, we need to check whether it is divisible by 400 or not. > > ClassAssignmentEx2 ©LeapYearDecider javaclassnotes.assignments javaclassnotes.assignments ClassAssignmentEx2() LeapYearDecider() main(String):void A isLeapYear(int):booleanarrow_forwardAdd a method called multiplesOfFive to the Exercise class. The method must have a void return type and take a single int parameter called limit. In the body of the method, write a while loop that prints out all multiples of 5 between 10 and limit (inclusive) on a single line. For instance, if the value of limit were 15 then the method will print: 10 15 You can use the printEvenNumbers method that is already in the Exercise class as an example to help you work out how to complete this method. In the main method of the Main class, add a call on the Exercise object to your multiplesOfFive method that prints the multiples of 5 between 10 and 25. Add a method called sum to the Exercise class. The method must have a void return type and take no parameters. In the body of the method, write a while loop to sum the values 1 to 10 and print the sum once the loop has finished. In the main method of the Main class, add a call on the Exercise object to your sum method. Check that it prints: 55 Add…arrow_forwardFor this exercise, we are going to look at how we can create a .equals method. Remember, to compare objects, we cannot just use ==. We need to create a criteria to determine if the objects are equal. In our case, we will say that two people are the same if both the name and birthday match. We are going to write a program that prompts the user for a person’s name and birthday and a student’s name, birthday, and grade, and decide if they are the same person. Start in the Person class creating the .equals method. Remember, this should take the other Person as an input and return a boolean if both the name and birthday are equal. Once completed, create the tester class where you will prompt the user for information. Sample output is provided below. Sample Output Please enter the Person's name: Tanner Please enter the Person's birthday: 5/4/2005 Please enter the Student's name: Tanner Please enter the Student's birthday: 5/4/2005 Please enter the Student's grade: 12 Same: true Please enter…arrow_forward
- For this exercise, we are going to look at how we can create a .equals method. Remember, to compare objects, we cannot just use ==. We need to create a criteria to determine if the objects are equal. In our case, we will say that two people are the same if both the name and birthday match. We are going to write a program that prompts the user for a person’s name and birthday and a student’s name, birthday, and grade, and decide if they are the same person. Start in the Person class creating the .equals method. Remember, this should take the other Person as an input and return a boolean if both the name and birthday are equal. Once completed, create the tester class where you will prompt the user for information. Sample output is provided below. Sample Output Please enter the Person's name: Tanner Please enter the Person's birthday: 5/4/2005 Please enter the Student's name: Tanner Please enter the Student's birthday: 5/4/2005 Please enter the Student's grade: 12 Same: true…arrow_forwardGiven a list of scores and a passing score, you are asked to find out the average score and the number of scores which are equal to or higher than the passing score. For examples, the list of scores is as follows: 46, 58, 56, 59, 89, 93, 77, 98, 100, 64 If the passing score is 60, then the answers should be 74 and 6. If the passing score is 55, then the answers should be 74 and 9. Implement the above task using MIPS in QtSpim. Initialize the array of scores in memory using any integer values between 0 and 100. The passing score should be obtained from user’s input and the answer must be printed out. See the following screen snapshot for reference.arrow_forwardUpdate Bresenham’s line (JAVA) method such that you can scale the line before drawing it. Normally, you pass two points and a Graphics’ object to draw line using Bresenham’s algorithm. Now you’ll add scaling factors in arguments for scaling as shown below. public void drawBresenhamLine(Point p1, Point p2, double Sx, double Sy, Graphics g) { //Write your code here } Note: If you use scaling method, then also write Scale method in solution. Answer:arrow_forward
- Update Bresenham’s line (JAVA) method such that you can scale the line before drawing it. Normally, you pass two points and a Graphics’ object to draw line using Bresenham’s algorithm. Now you’ll add scaling factors in arguments for scaling as shown below. public void drawBresenhamLine(Point p1, Point p2, double Sx, double Sy, Graphics g){//Write your code here}Note: If you use scaling method, then also write Scale method in solution.arrow_forwardIN JAVA Alice and Bob are playing a board game with a deck of nine cards. For each digit between 1 to 9, there is one card with that digit on it. Alice and Bob each draw two cards after shuffling the cards, and see the digits on their own cards without revealing the digits to each other. Then Alice gives her two cards to Bob. Bob sees the digits on Alice’s cards and lays all the four cards on the table in increasing order by the digits. Cards are laid facing down. Bob tells Alice the positions of her two cards. The goal of Alice is to guess the digits on Bob’s two cards. Can Alice uniquely determine these two digits and guess them correctly? Input The input has two integers p,q (1≤p<q≤9) on the first line, giving the digits on Alice’s cards. The next line has a string containing two ‘A’s and two ‘B’s, giving the positions of Alice’s and Bob’s cards on the table. It is guaranteed that Bob correctly sorts the cards and gives the correct positions of Alice’s cards. Output If Alice can…arrow_forwardTYPEWRITTEN ONLY PLEASE UPVOTE. DOWNVOTE FOR HANDWRITTEN. DO NOT ANSWER IF YOU ALREADY ANSWERED THIS. THE BIG NUMBER IN THE SIDE IS FOR NUMBERING.arrow_forward
- Stuck on Java again. Have to complete this using for-loops but everything I've tried has just given me errors. Any help would be appreciated!arrow_forwardImplement the class Character The role should be “primary” or “secondary” all other values are not acceptable. Considercapital and small letters variance. The gender should be “m” or “M” for male or “f” or “F” for female. The age should be a positive value. The giveRaise method increase the salary of a character by a given percentage with amaximum salary of 10000. The toString method returns a string that describes the character. For example: [Elisabeth Kane, female, 35, primary,4500$] 2) Implement the class Play A Play can have at most 20 characters. The real number of characters is registered in nbOfCharacters and is updated automaticallywhen a new character is added. AddCharacter method adds a new character to the characters array and updates thenbOfCharacters value. The attribute nbPlay keeps track of the number of Plays created. The toString method returns a string description of the play including name, genre and thenames of all the characters.Example: [The Opera…arrow_forwardSuppose that a friend tells you a phone number that you need to dial, as soon as you are done talking. You don’t have a pencil, so you remember it by grouping it into two sections, one with three digits, and one with four digits. The method you have used is calledarrow_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