12/13/2014

DCT1093 OOP: LAB WEEK 3


Identify the types of the following problems:-
(A=sequence Only, B=Selective,C=Iteration)

No
Problems
*Types (please Tick)
A
B
C
1
(Converting Fahrenheit to Celsius) Write a program that reads a Fahrenheit degree in double, then converts it to Celsius and displays the result in a message dialog box. The formula for the conversion is as follows:
celsius = (5/9) * (fahrenheit - 32)

 /


2
(Summing a series) Write a program to input a positive integer (n) and sum the following series:
1+2+3+….+n



 /
3
(Computing the volume of a cylinder) Write a program that reads in the radius and length of a cylinder and computes its volume using the following formulas:
   Area
= radius * radius * p
  volume
= area * length


 /


4
(Checking whether a number is even) Write a program that reads an integer and checks whether it is even. For example, if your input is 25, the output should be:
Is 25 an even number? False
If your input is 2000, the output should be:
Is 2000 an even number? true



 /

5
(Converting feet into meters) Write a program that reads a number in feet, converts it to meters, and displays the result. One foot is 0.305 meters.

 /


6
(Finding the highest score) Write a program that prompts the user to enter the number of students and each student's name and score, and finally displays the student with the highest score.

import java.util.Scanner;

public class labweek3grp2 {
   
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int N;
        System.out.println("Sila masukkan satu nilai");
        N= input.nextInt();
        if(N%2==0)
            System.out.println(N+"ialah nombor genap");
            else
        System.out.println(N+"ialah nombor ganjil");           
    }
}

 /
 /
7
(Calculating tips) Write a program that reads the subtotal and the gratuity rate, and computes the gratuity and total. For example, if the user enters 10 for subtotal and 15% for gratuity rate, the program displays $1.5 as gratuity and $11.5 as total.

 /


8
(Conversion from kilograms to pounds) Write a program that displays the following table (note that 1 kilogram is 2.2 pounds):
Kilograms Pounds
1         2.2
3         6.6
 
...
197       433.4
199       437.8



 /

9
(Finding the largest) Write a program that input two integers and find the largest.
import java.util.Scanner;

public class labweek3grp2 {
   
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int A,B;
        System.out.println("Sila masukkan dua nilai");
        A= input.nextInt();
        B= input.nextInt();
        if(A>B)
        System.out.println(A + " Paling besar");
            else
        System.out.println(B+ " Paling besar");           
    }
}

 /

10
(Finding the largest) Write a program that input three integers and find the largest.
import java.util.Scanner;

public class labweek3grp2 {
   
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int A,B,C,TBSR;
        System.out.println("Sila masukkan tiga nilai");
        A= input.nextInt();
        B= input.nextInt();
        C= input.nextInt();
        if(A>B)
        TBSR=A;
            else
        TBSR=B;
       
        if(C>TBSR)
        TBSR=C;
       
        System.out.println(TBSR+ " Paling besar");           
   
   
    }
}

 /

11
(Finding the largest) Write a program that input ten integers and find the largest.


 /
 /
12
 SATU Terengganu charges the following rates for its customer:-

Penggunaan
Caj
Minima (RM)
Kuantiti M3
(Meter Padu)
Caj
Setiap M3
0 - 20.00
RM0.42
RM4.00 sebulan
20.1 - 40.00
RM0.65
40.1 - 60.00
RM0.90
60.1 ke atas
RM1.00
.




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