C语言题目 求大神给个正确答案我对对。。。

PART A

Below is some code for the classes Student and Tutorial. You are required to add your own code to these classes and answer the following questions:

Q1. In the class Student, declare the class attributes name, age, address. Select the most appropriate data types for these attributes.

Q2. Create an alternate constructor for class Student that has 3 input parameters, one for each of the class attributes listed above. Initialise the class attributes to these input parameter values in the constructor of class Student.

Q3. In the class Student, create a procedure called display() that will display the name and age of the Student. Both are to be displayed on one line.

Q4. In the class Student, create a procedure called readAge() that will ask the user of the program to enter the age for the Student (use Scanner). If the age entered is greater than 16, display the message “Student age is valid”, otherwise display “Student age is NOT valid”.

WRITE THE CODE FOR CLASS STUDENT ON THE NEXT PAGE

class Student
{
}

Q5. In the main method of class Tutorial, declare and create two Student objects, call them anything you like. You must use the alternate constructor for Student to do this.

Q6. In the main method of class Tutorial, after creating the two student objects, call display() and readAge() for each student object.

Write the code for Tutorial here:

class Tutorial
{

public static void main(String args[])
{
}
}// End of class Tutorial

PART B

Q1. Write down the correct way to declare and create an object using the following Constructor method headers:

Laptop(String model, double version, double cost)

Keyboard(int id, String type)

Account(int number, boolean current, double balance)

Phone(String name, double price, char code)

Car(String registration, double mileage, double cost)

Q2. What is wrong with this code? Correct the errors, then write down what the output will be after the code executes.

Double amount = “3.75”;
if(amount = 100 || amunt => 50);
{
  System.out.println("Amount is: " + amount);
}
else (amount == 3.75)
{
amount = 5.2;
  System.out.println("Amount is: " + amount);
}

搞笑吧,这是java,根本不是c++, 更别提c语言了,你到底是要哪个语言去写追问

java。。。

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答