Lab Report # 3
Lab Report # 3
Lab Report No 3
OOP
Submitted By:
Abdullah (010)
Muhammad Ahmad (035)
Ahmed Abdullah (054)
Submitted to:
Miss Sibgha Batool
Dated:
Week 03
import java.util.Scanner;
2
Lab Task No 2
Write a program in C++ to input marks obtained by a student in a subject. The
total marks are 100. Find out the grade of the student by using the if-else
nested structure. The grade is:
If marks are equal to or greater than 90, grade is A.
If marks are equal to or greater than 70 and less than 90, grade is B.
If marks are equal to or greater than 50 and less than 70, grade is C.
If marks are less than 50, grade is “F”.
Solution:
Brief description (3-5 lines)
In this program, we have used the if-else statement that can take many conditions and execute
accordingly
First the user enters marks and the conditions are checked one by one and marks are displayed
The code
import java.util.Scanner;
3
4
Lab Task No 3
Write a program which take input from user and check that whether that
letter is vowel or not?
Solution:
Brief description (3-5 lines)
In the below program we have used if else statement and given many conditions in if
For the input of a character type charat() is used.
The code
import java.util.Scanner;
The code
import java.util.Scanner;
Print table and get table number from user using for loop.
Solution:
Brief description (3-5 lines)
In this program we have used for loop to print the table of the user input
The code
import java.util.Scanner;
Solution:
Brief description (3-5 lines)
In this program we have used nested for loop outer loop is for the rows and the outer for loop is for
the columns
And characters have been printed using the ASCII code
The code
import java.util.Scanner;
Write a program in java to display the given below patter using nested loop.
Solution:
Brief description (3-5 lines)
In this program we have used 3 for loops one loop for the number of rows inner first loop for printing
spaces pattern and second inner loop for the numbers
%-7d is a format specifier string used in printf that is used to print formatted strings
The code
import java.util.Scanner;