Object Oriented Programming CE-102T/CE-102L
Object Oriented Programming CE-102T/CE-102L
Object Oriented Programming CE-102T/CE-102L
Programming
CE-102T/CE-102L
-Section: B
-SUBMITTED BY:
o Abrar Manzoor 2020F-BCE-055
o Osaid Mirza 2020F-BCE-057
o Aisha Irshaad 2020F-BCE-80
o Arisha Khan 2020F-BCE-82
- Department: Computer Engineering
Contents
Introduction to
Mark Sheet
Acknowledgment JAVA
Generator System
Programming
Click to add text
Object Oriented
Project Overview Commands
programming
SYSTEM HARDWARE
Processor : Intel Core i3
Hard disk : 20GB or more than 20GB
RAM : 1GB
Printer : to print the required documents
Compact Drive
SYSTEM SOFTWARE
Operating System :Windows 7
Turbo C :For execution of program
Ms Word :For Presentation output
OBJECT ORIENTED PROGRAMMING (OOP):
• IF ELSE:
• Java has the following conditional statements: Use if to specify a block of code to be executed, if a specified
condition is true. Use else to specify a block of code to be executed, if the same condition is false. Use else if
to specify a new condition to test, if the first condition is false.
• SWITCH:
• A switch statement allows a variable to be tested for equality against a list of values. Each value is called a
case, and the variable being switched on is checked for each case.
• LOOP:
• The Java for loop is a control flow statement that iterates a part of the programs multiple times. The Java while loop is a control flow statement that
executes a part of the programs repeatedly on the basis of given boolean condition.
• WHILE LOOP:
• Java while loop is a control flow statement that allows code to be executed repeatedly based on a given Boolean condition. The while loop can be
thought of as a repeating if statement. The various parts of the While loop are: Test Expression: In this expression we have to test the condition.
• NESTED LOOP:
• Nested loop means a loop statement inside another loop statement.
• ARRAY:
• Java array is an object which contains elements of a similar data type. In Java, array is an object of a dynamically generated class. Java array inherits the Object class and implements the Serializable as well as Cloneable
interfaces. We can store primitive values or objects in an array in Java.
• Multidimensional Array.
• CONSTRUCTOR
• A constructor in Java is a special method that is used to initialize objects. The constructor is called when an object of a class is created.
• METHOD OVERLOADING
• In other words, we can say that Method overloading is a concept of Java in which we can create multiple methods of the same name in the same class, and all methods work in different ways. When more than one
method of the same name is created in a Class, this type of method is called Overloaded Method
• POLYMORPHISM IN JAVA
• Polymorphism in Java is a concept by which we can perform a single action in different ways.
So, polymorphism means many forms. There are two types of polymorphism in Java:
compile-time polymorphism and runtime polymorphism. We can perform polymorphism in
java by method overloading and method overriding
• INHERITANCE IN JAVA
• In Java, it is possible to inherit attributes and methods from one class to another. We group
the "inheritance concept" into two categories: subclass (child) - the class that inherits from
another class. superclass (parent) - the class being inherited from.
• CONSTRUCTOR OVERLOADING
• Java Constructor overloading is a technique in which a class can have any number of
constructors that differ in parameter list. The compiler differentiates these constructors by
taking into account the number of parameters in the list and their type.
MAIN
/*
* To change this license header, choose License Headers in
Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Abrar Manzoor
*/
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
public class MarkSheetGenerator extends StudentInfo {
Scanner sc=new Scanner(System.in);
int total(int mark[]){
int sum=0;
for (int i = 0; i < mark.length; i++) {
sum=sum+mark[i];
}
return sum;
}
float Percentage(int total,int totalmarks){
return (total*100) / totalmarks;
}
@Override
public void Marksheet(){
super.Marksheet();
System.out.println("Enter total number of Courses: ");
int course=Integer.parseInt(sc.nextLine());
String subj[];
subj=new String[course];
for (int i = 0; i < subj.length; i++) {
int s=i+1;
System.out.println("Enter Course name "+s);
subj[i]=sc.nextLine();
}
int marks[]=new int[subj.length];
for (int i = 0 ; i < subj.length; i++) {
System.out.println("Enter the marks of "+subj[i]+":");
marks[i]=sc.nextInt();
}
int totalmarks=subj.length*100;
int total=total(marks);
System.out.println("Total Marks:"+total);
System.out.println("Percentage:"+Percentage(total,totalmarks));
System.out.println("DO you want to print Mark Sheet(Y/N):");
char opt=sc.next().charAt(0);
if(opt=='Y' || opt=='y'){
try{
String filename=getRoll()+".text";
PrintWriter out=new PrintWriter(filename);
out.println("\t\t\t\tMarksheet\t\t\t");
out.println("Roll Numer: "+getRoll());
out.println("Student Name: "+getFull_name());
out.println("Father Name: "+getFather_Name());
out.println("Batch: "+getBatch());
out.println("Department: "+getBatch());
out.println("\n\n");
out.println("Courses\t\t\tMarks");
for (int i = 0; i < subj.length; i++) {
out.println(subj[i]+"\t\t\t"+marks[i]);
}
out.println("\n\nTotal Marks: "+totalmarks);
out.println("Marks Obtained: "+total);
float perc=Percentage(total,totalmarks);
out.println("Percentage: "+perc+"%");
out.close();
}
catch(Exception e){
System.out.println(e);
}
}
else{
}}
STUDENT INFO:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package MarksheetGenerator;
/**
*
* @author Abrar Manzoor
*/
import java.util.Scanner;
public class StudentInfo {
String roll;
String full_name;
String Father_Name;
int batch;
String dept;
public String getFull_name() {
return full_name;
}
public void setFull_name(String full_name) {
this.full_name = full_name;
}