SlideShare a Scribd company logo
TEST PROGRAM TAKEN FROM THE
PREVIOUS LESSONS
REMINDERS IN CREATING A CLASS
Make sure that
your class is inside
of the scr
CREATING CONSTRUCTOR ,
OBJECT AND METHOD
import java.util.*;
public class CalcAverage {
public CalcAverage(String name) {
//this is a constructor with
parameter, name
System.out.println("My name is " + name);
}
//Creating method
public static void getAve(float ave) {
System.out.println("The average is:" + ave);
}
//Creating method
public static void getSum(float sum) {
System.out.print("The sum is:" + sum);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner Input = new Scanner (System.in);
//creating object
CalcAverage myName = new CalcAverage("Analyn");
CONTINUATION:
//variable declaration
float prelim,midterm,sf,f,sum;
float ave;
System.out.print("Enter Prelim Grade:");
prelim = Input.nextFloat();
System.out.print("Enter Midterm Grade:");
midterm = Input.nextFloat();
System.out.print("Enter Semi-final Grade:");
sf = Input.nextFloat();
System.out.print("Enter Final Grade:");
f = Input.nextFloat();
//calculation
sum = prelim + midterm + sf + f;
ave = sum/4;
//calling the method
getAve(ave);
getSum(sum);
Input.close();
return ;
}
}
OUTPUT:
My name is Analyn
Enter Prelim Grade:89.3
Enter Midterm Grade:89
Enter Semi-final Grade:90.3
Enter Final Grade:94.8
The average is:90.850006
The sum is:363.40002

More Related Content

PDF
Class 6 2ciclo
PPTX
Rx – reactive extensions
DOCX
Ete programs
PPT
Booa8 Slide 09
DOC
5 Rmi Print
PPT
Md11 gui event handling
KEY
Javascript3
PDF
Examples of sql queries
Class 6 2ciclo
Rx – reactive extensions
Ete programs
Booa8 Slide 09
5 Rmi Print
Md11 gui event handling
Javascript3
Examples of sql queries

What's hot (20)

PPTX
Java this keyword ppt with example
PDF
Method swizzling
DOCX
PDF
Introduction to RxJS
DOCX
Java Programs
DOCX
PPTX
PDF
What's new in Swift 3
DOCX
Pratik Bakane C++
PDF
NodeJS Spring style Inversifyjs
KEY
Two-StageCreation
DOCX
Pratik Bakane C++
PDF
Your IDE Deserves Better
DOCX
Program: Inheritance in Class - to find topper out of 10 students
DOCX
WAP to find out whether the number is prime or not in java
DOCX
Linked list imp of list
DOCX
Concatenation of two strings using class in c++
PDF
ReactiveCocoa in Practice
DOCX
Pratik Bakane C++
Java this keyword ppt with example
Method swizzling
Introduction to RxJS
Java Programs
What's new in Swift 3
Pratik Bakane C++
NodeJS Spring style Inversifyjs
Two-StageCreation
Pratik Bakane C++
Your IDE Deserves Better
Program: Inheritance in Class - to find topper out of 10 students
WAP to find out whether the number is prime or not in java
Linked list imp of list
Concatenation of two strings using class in c++
ReactiveCocoa in Practice
Pratik Bakane C++
Ad

Similar to Test program (20)

DOCX
DOCX
Java programs
ODT
Java practical
DOCX
Unit-3 Practice Programs-5.docx
PPTX
Java Programs
PDF
Java doc Pr ITM2
PPTX
java input & output statements
PDF
Object Oriented Solved Practice Programs C++ Exams
DOCX
Rizal's Life
PPTX
Object Oriented Programming Inheritance with case study
DOCX
Main Java[All of the Base Concepts}.docx
DOCX
Java Programs Lab File
DOCX
2. Create a Java class called EmployeeMain within the same project Pr.docx
DOCX
All Of My Java Codes With A Sample Output.docx
PPTX
Inheritance
PPTX
Lecture 4_Java Method-constructor_imp_keywords
PPTX
Test Program - Basic operators
PDF
Description (Part A) In this lab you will write a Queue implementati.pdf
PDF
Lec 5 13_aug [compatibility mode]
PDF
OOPs & Inheritance Notes
Java programs
Java practical
Unit-3 Practice Programs-5.docx
Java Programs
Java doc Pr ITM2
java input & output statements
Object Oriented Solved Practice Programs C++ Exams
Rizal's Life
Object Oriented Programming Inheritance with case study
Main Java[All of the Base Concepts}.docx
Java Programs Lab File
2. Create a Java class called EmployeeMain within the same project Pr.docx
All Of My Java Codes With A Sample Output.docx
Inheritance
Lecture 4_Java Method-constructor_imp_keywords
Test Program - Basic operators
Description (Part A) In this lab you will write a Queue implementati.pdf
Lec 5 13_aug [compatibility mode]
OOPs & Inheritance Notes
Ad

More from MLG College of Learning, Inc (20)

PPTX
PPTX
PC111-lesson1.pptx
PPTX
PC LEESOON 6.pptx
PPTX
PC 106 PPT-09.pptx
PPTX
PPTX
PPTX
PPTX
PC 106 Slide no.02
PPTX
PPTX
PPTX
PC 106 Slide 1.pptx
PDF
Db2 characteristics of db ms
PDF

Recently uploaded (20)

PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Institutional Correction lecture only . . .
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
01-Introduction-to-Information-Management.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Sports Quiz easy sports quiz sports quiz
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Classroom Observation Tools for Teachers
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
master seminar digital applications in india
PDF
Pre independence Education in Inndia.pdf
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
Basic Mud Logging Guide for educational purpose
PPTX
Cell Types and Its function , kingdom of life
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
Institutional Correction lecture only . . .
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
01-Introduction-to-Information-Management.pdf
human mycosis Human fungal infections are called human mycosis..pptx
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Sports Quiz easy sports quiz sports quiz
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Microbial diseases, their pathogenesis and prophylaxis
Classroom Observation Tools for Teachers
Final Presentation General Medicine 03-08-2024.pptx
VCE English Exam - Section C Student Revision Booklet
master seminar digital applications in india
Pre independence Education in Inndia.pdf
TR - Agricultural Crops Production NC III.pdf
Basic Mud Logging Guide for educational purpose
Cell Types and Its function , kingdom of life
Microbial disease of the cardiovascular and lymphatic systems
3rd Neelam Sanjeevareddy Memorial Lecture.pdf

Test program

  • 1. TEST PROGRAM TAKEN FROM THE PREVIOUS LESSONS
  • 2. REMINDERS IN CREATING A CLASS Make sure that your class is inside of the scr
  • 3. CREATING CONSTRUCTOR , OBJECT AND METHOD import java.util.*; public class CalcAverage { public CalcAverage(String name) { //this is a constructor with parameter, name System.out.println("My name is " + name); } //Creating method public static void getAve(float ave) { System.out.println("The average is:" + ave); } //Creating method public static void getSum(float sum) { System.out.print("The sum is:" + sum); } public static void main(String[] args) { // TODO Auto-generated method stub Scanner Input = new Scanner (System.in); //creating object CalcAverage myName = new CalcAverage("Analyn");
  • 4. CONTINUATION: //variable declaration float prelim,midterm,sf,f,sum; float ave; System.out.print("Enter Prelim Grade:"); prelim = Input.nextFloat(); System.out.print("Enter Midterm Grade:"); midterm = Input.nextFloat(); System.out.print("Enter Semi-final Grade:"); sf = Input.nextFloat(); System.out.print("Enter Final Grade:"); f = Input.nextFloat(); //calculation sum = prelim + midterm + sf + f; ave = sum/4; //calling the method getAve(ave); getSum(sum); Input.close(); return ; } }
  • 5. OUTPUT: My name is Analyn Enter Prelim Grade:89.3 Enter Midterm Grade:89 Enter Semi-final Grade:90.3 Enter Final Grade:94.8 The average is:90.850006 The sum is:363.40002