3/09/2015

DCT1093 OOP: Asgmt 3.

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.                                        

No comments:

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.  ...