Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

QUESTION 21 How many times is “Hello” displayed? count = 0; while (count < 3) {

ID: 3726936 • Letter: Q

Question

QUESTION 21

How many times is “Hello” displayed?

count = 0;
while (count < 3) {
    System.out.println("Hello");
}
count = count + 1;

QUESTION 22

Use the partial class definition to answer questions 22 to 26 below.

public class Car {
    private String make;
    private String model;
    private int year;
}

Write a constructor for the Car class that will accept three input arguments as the values of the attributes.

QUESTION 23

Write an overloaded constructor for the Car class that will except a single argument for the make of the car.

QUESTION 24

Write a setter method for the year attribute.

QUESTION 25

Write a getter method for the make attribute.

5 points   

QUESTION 26

Complete a main method that will accomplish the following steps. (You may assume that the class includes all appropriate setter methods and getter methods for all instance variables.)

Create a 2015 Honda Accord.

Create a 2017 Ford Escape.

Change the year of the Honda Accord to 2013.

Print the make of the Escape.

QUESTION 27

Write a method that meets the requirements of the following comment.

// findLowestPrice
//
// the purpose of this method is to find the lowest price among 3 prices.
//
// Input Arguments: price1, price2, price3
//                  three prices, as double types
// Return Value:   minPrice
//                  the smallest price value

QUESTION 28

Write a method that meets the requirements of the following comment.

// printHigherBank
//
// The purpose of this method is to print the name of the bank that provides the
// larger rate. If both rates are the same, print the name of the first bank.
//
// Input Arguments: bankName1, rate1, bankName2, rate2
//                  the names two banks (as Strings)
//                  and the rates they offer (as doubles)
// Return Value:    none

QUESTION 29

Write a method named isMultiple that determines if the first integer is a multiple of the second integer. (Hint: An integer is a multiple of another integer if there is a remainder of 0 when the first integer is divided by the second). Return true if the first integer is a multiple of the second, or false if it is not.

QUESTION 30

Write a main method that uses the isMultiple method from question 29 to determine if one integer is a multiple of another integer. Prompt the user for two integers, then accept the two integers from the user. Print a message that states whether or not the first integer is a multiple of the second integer.

Explanation / Answer

Hi, I have implemented first 5 Questions.

Please repost others in separate post.

QUESTION 21

How many times is “Hello” displayed?

count = 0;

while (count < 3) {

System.out.println("Hello");

}

count = count + 1;

Ans: Infinite times because "count" value is not getting increas in while loop

QUESTION 22

Use the partial class definition to answer questions 22 to 26 below.

public class Car {

private String make;

private String model;

private int year;

}

Write a constructor for the Car class that will accept three input arguments as the values of the attributes.

public class Car {

private String make;

private String model;

private int year;

public Car(String m, String mo, String y) {

make = m;

model = mo;

year = y;

}

}

QUESTION 23

Write an overloaded constructor for the Car class that will except a single argument for the make of the car.

public class Car {

private String make;

private String model;

private int year;

public Car(String m, String mo, String y) {

make = m;

model = mo;

year = y;

}

public Car(String m) {

make = m;

}

}

QUESTION 24

Write a setter method for the year attribute.

public class Car {

private String make;

private String model;

private int year;

public Car(String m, String mo, String y) {

make = m;

model = mo;

year = y;

}

public Car(String m) {

make = m;

}

public void setYear(int y) {

year = y;

}

}

QUESTION 25

Write a getter method for the make attribute.

public class Car {

private String make;

private String model;

private int year;

public Car(String m, String mo, String y) {

make = m;

model = mo;

year = y;

}

public Car(String m) {

make = m;

}

public void setYear(int y) {

year = y;

}

public String getMake() {

return make;

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote