Advertisement
ismail5g

Q-a

Apr 15th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. import java.util.Scanner;
  2. class student{
  3.     int id;
  4.     int semesterno;
  5.     String name;
  6.     String course;
  7.     double cgpa;
  8.     double gpa;
  9.    
  10.     student(String n, int i, int sn, double g){
  11.         name=n;
  12.         id= i;
  13.         semesterno=sn;
  14.         gpa=g;
  15.     }
  16.     double cgpacalculate(double java, double algo, double database){
  17.         return cgpa=(java+algo+database)/3;
  18.     }
  19.     void display(){
  20.         System.out.println("Student ID: "+id);
  21.         System.out.println("Student Name: "+name);
  22.         System.out.println("Semester No: "+semesterno);
  23.         System.out.println("CGPA: "+cgpa);
  24.     }
  25. }
  26.  
  27. class Solve{
  28.     public static void main(String[] args){
  29.         student std = new student("ismail", 17135196, 4, 3.55);
  30.         std.cgpacalculate(3.94, 3.88, 4.00);
  31.         std.display();
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement