0% found this document useful (0 votes)
3 views

ObjectOrientedProgramming_Tutorial1

the first tutorial answered for the Object Oriented Programming course in UCSI University
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

ObjectOrientedProgramming_Tutorial1

the first tutorial answered for the Object Oriented Programming course in UCSI University
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

BIC1224 Object Oriented Programming

Student Name: Jawad Hassan Khan


Student Id: 1002371785

Tutorial 1

Write the java programs for the following problems.

NOTE: THE CODE OF THE WHOLE TUTORIAL IS ON PAGE NUMBER 3.

1. Write a java application which display your name, your ID and program in separate lines.

2. (Display three messages) Write a program that displays “Welcome to OOP course”,
“Welcome to ICSDI”, and “Programming is fun”.

3. (Display five messages) Write a program that displays “Welcome to OOP course”
seven times.

Page 1 of 4
BIC1224 Object Oriented Programming

4. (Display a pattern) Write a program that displays the following pattern:

5. (Print a table) Write a program that displays the following table:

6. (Compute expressions) Write a program that displays the result of

Page 2 of 4
BIC1224 Object Oriented Programming

7. (Summation of a series) Write a program that displays the result of 1 + 2 + 3 + 4 + 5 + 6


+ 7 + 8 + 9.

8. Write a program that converts a Fahrenheit degree to Celsius using the formula:

celsius ( 95 )( fahrenheit  32)

CODE OF THE WHOLE TUTORIAL:

import java.util.Scanner;
public class helloworld {
public static void main(String[]args){
System.out.println("-----------Q1-----------");
System.out.println("Name: Jawad Hassan Khan");
System.out.println("ID: "+ 1002371785);
System.out.println("Prefer Game: Badminton");

System.out.println();

System.out.println("-----------Q2-----------");
System.out.println("Welcome to OOP course\nWelcome to ICSDI\nProgramming is fun");

System.out.println();
System.out.println("-----------Q3-----------");
for (int i = 0; i < 7; i++) {
System.out.println("Welcome to OOP course");
}

Page 3 of 4
BIC1224 Object Oriented Programming

System.out.println("-----------Q4-----------");
System.out.println();
System.out.println(" J A V v A ");
System.out.println(" J A A V V A A ");
System.out.println(" J J AAAAA V V AAAAA ");
System.out.println(" J J A A V A A ");

System.out.println();
System.out.println("-----------Q5-----------");
System.out.println("a a^2 a^3");
System.out.println("1 1 1 ");
System.out.println("2 4 8 ");
System.out.println("3 9 27 ");
System.out.println("4 16 64 ");

System.out.println();
System.out.println("-----------Q6-----------");
double expression = 0;
expression = (9.5 * 4.5 - 2.5 * 3)/(45.5-3.5);
System.out.println("Answer to the expression = "+ expression);

System.out.println();
System.out.println("-----------Q7-----------");
int sum=0;
for (int i = 1; i < 10; i=i+1) {
sum=sum+i;
System.out.println(sum);
}

System.out.println("-----------Q8-----------");
Scanner read = new Scanner(System.in);

System.out.print("Enter the temperature in Fahrenheit: ");


double fahrenheit = read.nextDouble();
double celsius = (fahrenheit-32.0)*(5.0/9.0);
System.out.println("The temperature in celsius: "+celsius);

}
}

*Please copy all your work into one Microsoft word file and submit it via CN.

Page 4 of 4

You might also like