PRO192_-_PE_-_SU_2023_-_1_HCM_ca_14h_275.webp
H

PRO192_-_PE_-_SU_2023_-_1_HCM_ca_14h_275.webp

1 of 1
Paper No: 1
Question 1:
Question 1: (2 marks)
Read PE instructions at the bottom of the exam paper.
Do not pay attention to real meaning of objects, variables and their values in the questions below.Write a class ElectricMotor (in the default package of the NetBean) with the following information:
ElectricMotor
Where:
-name:String-voltage:int
ElectricMotor() default constructor.ElectricMotor(name: String, voltage:int,
-current:int
current:int) constructor, which sets values to name, voltage and current of the electric motor.
+ElectricMotor()
+ElectricMotor(name: String, voltage:int, current:int)
+getName():String+getPower():int
getName():String returns the name of the motor in uppercase format.
+setVoltage(volt:int):void
getPower(): int returns the motor power calculated as voltage times current set Voltage(volt:int):void voltage update.
+setCurrent(cur:int):void
Zoom
Valid values are between 110 and 220. If it is out of range, print out "Invalid value"setCurrent(curr:int):void current update.
Valid value is greater than 0. If value is less than or equal to 0, print out "Invalid value"
Do not format the result.
The main class is ready to test the program. The program output might look something like:
Enter name: toshiba
Enter name: toshiba
Enter voltage: 220
Enter current: 2
1. Test getName()
2. Test getPower()
Enter voltage: 220
Enter current: 2
1. Test getName()
2. Test getPower()
3. Test set Voltage()
3. Test set Voltage()
Enter TC (1, 2 or 3): 2
Enter TC (1,2 or 3): 3
Enter new voltage: 300
OUTPUT:
OUTPUT:440
Invalid value
+ 80%
Close
Chưa có bình luận nào.

Thông tin

Category
PRO192
Thêm bởi
Happy2001
Ngày thêm
Lượt xem
5,767
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Image metadata

Filename
PRO192_-_PE_-_SU_2023_-_1_HCM_ca_14h_275.webp
File size
66.9 KB
Dimensions
1536px x 793px

Share this media

Back
Bên trên Bottom