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

PARTABelowissomecodefortheclassesStudentandTutorial.Youarerequiredtoaddyourowncodetot... 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);
}
展开
 我来答
不是骗子的贼
2016-07-23 · TA获得超过155个赞
知道小有建树答主
回答量:690
采纳率:0%
帮助的人:240万
展开全部
搞笑吧,这是java,根本不是c++, 更别提c语言了,你到底是要哪个语言去写
追问
java。。。
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式