Given statements: //Switch to score switch (score) { //Case case (score > 90): //Assign the grade grade = 'A'; //Break the statement break; //Case case (score > 80): //Assign the grade grade = 'b'; //Break the statement break; //Case case (score > 70): //Assign the grade grade = 'C'; //Break the statement break; //Case case (score > 60): //Assign the grade grade = 'D'; //Break the statement break; //Default Case default: //Assign the grade grade = 'F'; } Error in the given statement: Error #1: The case statements itself cannot contain an expression. The “case” must be carried out with an integer or a character. The given code cannot be modified as the “switch” statement because it contains expressions. It can only be converted into “if-else-if” statement that is given below...
Given statements: //Switch to score switch (score) { //Case case (score > 90): //Assign the grade grade = 'A'; //Break the statement break; //Case case (score > 80): //Assign the grade grade = 'b'; //Break the statement break; //Case case (score > 70): //Assign the grade grade = 'C'; //Break the statement break; //Case case (score > 60): //Assign the grade grade = 'D'; //Break the statement break; //Default Case default: //Assign the grade grade = 'F'; } Error in the given statement: Error #1: The case statements itself cannot contain an expression. The “case” must be carried out with an integer or a character. The given code cannot be modified as the “switch” statement because it contains expressions. It can only be converted into “if-else-if” statement that is given below...
The case statements itself cannot contain an expression. The “case” must be carried out with an integer or a character. The given code cannot be modified as the “switch” statement because it contains expressions. It can only be converted into “if-else-if” statement that is given below...
You can use Eclipse later for program verification after submission.
1. Create an abstract Animal class. Then, create a Cat class. Please implement all the methods and inheritance
relations in the UML correctly:
Animal
name: String
# Animal (name: String)
+ getName(): String
+ setName(name: String): void
+ toString(): String
+ makeSound(): void
Cat
breed : String
age: int
+ Cat(name: String, breed: String, age: int)
+ getBreed(): String
+ getAge (): int
+ toString(): String
+ makeSound(): void
2. Create a public CatTest class with a main method. In the main method, create one Cat object and print the
object using System.out.println(). Then, test makeSound() method.
Your printing result must follow the example output:
name: Coco, breed: Domestic short-haired, age: 3
Meow Meow
automata theory can please wright the exact language it know for example say it knows strings start 0 and end with 1 this is as example also as regular expression
Chapter 4 Solutions
Starting Out with Java: Early Objects (6th Edition)