3. Suppose that a class named Bicycle contains a private nonstatic integer named
ID: 3838375 • Letter: 3
Question
3. Suppose that a class named Bicycle contains a private nonstatic integer named height, a public nonstatic string named model, and a public static integer named wheels. Which of the following are legal statements in a class named BicycleDemo that has instantiated an object as Bicycle myBike new Bicycle f. Bicycle. model Hurricane a. my Bike. height 26 b. myBike mode "Cyclone" g. Bicycle .int- 3; h. Bicycle .model 108; C. myBike Wheels 3 d. myBike model -108 i. Bicycle .wheels 2; e. Bicycle height 24; j. Bicycle your Bike myBikeExplanation / Answer
Question 3:
b. myBike.model = "Cyclone";
c. myBike.wheels = 3;
i. Bicycle.wheels= 2;
j. Bicycle yu = myBike;
Question 6:
import java.util.Scanner;
/**
* @author
*
*/
public class BookStoreCredit {
public static void main(String[] args) {
Scanner scanner = null;
try {
scanner = new Scanner(System.in);
// prompt to read name of student
System.out.print("Enter the Student name:");
String studentName = scanner.next();
// prompt to read grade point average of student
System.out.print("Enter the Student grade point average:");
double gradePointAvg = scanner.nextDouble();
// method call
display(studentName, gradePointAvg);
} catch (Exception e) {
// TODO: handle exception
}
}
/**
* method to compute the credit and display the name, grade point and credit
*
* @param studentName
* @param gradePointAvg
*/
public static void display(String studentName, double gradePointAvg) {
System.out.println("Student Name:" + studentName);
System.out.println("Grade point Average:" + gradePointAvg);
// compute the credit and display
System.out.println("Credit :" + (gradePointAvg * 10));
}
}
OUTPUT:
Enter the Student name:Srinivas
Enter the Student grade point average:3.2
Student Name:Srinivas
Grade point Average:3.2
Credit :32.0
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.