Assignment 3
1. Write a java program to input a length and width of a right triangle and output it area and perimeter. Use object oriented programming techniques based on *following UML class diagram.
*will be discussed in class
2. Write a class for each of the following specifications. In each case, include a constructor that set each member values to 0, a method named inputdata() that will prompt user to enter all values for it member data and a member method named showdata() that can be used to display member values.
i) A class named time that has integer data members named secs, mins, and hours.
import java.util.Scanner;
class time{
int secs,mins,hours;
time(){
secs=mins=hours=0;
}
void input_data(){
System.out.println("Sila masukkan saat, minit dan jam");
Scanner input = new Scanner(System.in);
secs = input.nextInt();
mins = input.nextInt();
hours = input.nextInt();
}
void showdata(){
System.out.println("Saat="+secs);
System.out.println("Minit="+mins);
System.out.println("Jam ="+hours);
}
}
public class asgmt3qa {
public static void main(String[] args) {
time mytime = new time();
mytime.showdata();
mytime.input_data();
mytime.showdata();
}
}
ii) A class named rectangle that has integer data members named height and length.
Subscribe to:
Post Comments (Atom)
Cara download Installer windows 10 dalam format ISO
1. Jika anda bercadang untuk download windows 10 melalui website rasmi windows - pilihan untuk download dalam format ISO tidak di berikan. ...
-
ANSWERS TO CHAPTER EXERCISES (CHAPTER 8) Review Questions 1. List and describe various types of output, including technolog...
-
Based on real life scenario on any local company/ organization which you are very familiar, define the problem that could be addressed thr...
-
A. Response to the following statements by circling either T (TRUE) or F (FALSE). [10M] I. 1. Java enables users...
No comments:
Post a Comment