Professional Documents
Culture Documents
Ilaans Record
Ilaans Record
Ilaans Record
*;
int roll;
System.out.println("enter name");
name=sc.nextLine();
dob=sc.nextLine();
roll=sc.nextInt();
System.out.println();
System.out.println();
System.out.print("Name : ");
System.out.println(name);
System.out.println(dob);
System.out.println(roll);
}
import java.util.*;
float p, c, m, cts, e;
char gd;
System.out.print("Physics : ");
p=sc.nextFloat();
System.out.print("Chemistry : ");
c=sc.nextFloat();
System.out.print("Math : ");
m=sc.nextFloat();
cts=sc.nextFloat();
System.out.print("English : ");
e=sc.nextFloat();
tot=p+c+m+cts+e;
per=tot/5;
if(per>=90)
gd='A';
else if(per>=60)
gd='B';
else if(per>=40)
gd='C';
else
gd='D';
System.out.println();
System.out.print("Physics : ");
System.out.println(p);
System.out.print("Chemistry : ");
System.out.println(c);
System.out.print("Math : ");
System.out.println(m);
System.out.println(cts);
System.out.print("English : ");
System.out.println(e);
System.out.println();
obj.inputdata();
obj.readdata();
obj.compute();
obj.printdata();
obj.showdata();
}
/*A class Iscores defines the scores of a candidate in six
subjects and another class bestfour defines the best of the four subjects:
Data Members:
int number[6][2] - contains marks for six subjects and subject code[numeric]
Member Functions:
int point() - to return the point in each subject according to the following:
Marks Points
>=90 1
80-89 2
70-79 3
60-69 4
50-59 5
40-49 6
00-39 7
Member Functions:
void bestsubjects() - to display the total points and best of four subjects
Specify the details of both the classes using the concept of inheritance.
Specify the details of the class, the functions and the main. */
number[i][j] = input;
if(marks>=90)
return 1;
else if(marks>=80)
return 2;
else if(marks>=70)
return 3;
else if(marks>=60)
return 4;
else if(marks>=50)
return 5;
else if(marks>=40)
return 6;
else
return 7;
}
void bestsubjects()
int total=0;
total+= point(number[1][i]);
int temp1;
int temp2;
int j;
j=i;
temp1=number[1][i];
temp2=number[0][i];
number[1][j]=number[1][j-1];
number[0][j]=number[0][j-1];
number[1][j]=temp1;
number[0][j]=temp2;
System.out.println(number[0][i]);
}
public class Account
accountNumber=accnum;
principal=prin;
void display()
double rate;
double time;
super(accnum,prin);
rate=r;
time=t;
double calculate()
return (super.principal*rate*time)/100;
void display()
{
double rate;
double time;
super(accnum,prin);
rate=r;
time=t;
double calculate()
void display()
}
import java.util.*;
int accountNum=sc.nextInt();
double principal=sc.nextDouble();
System.out.println("
}
/*Implement the following heirarchy
Class BankAc contains details about the account holder. New account number is obtained via a static
member AccNo which is incremented with every account creation.
Methods:-
deposit()
withdraw()
getBalance()
display()
Class SavingsAc inherits from BankAc and additionally stores rate of interest(monthly).
Methods:-
void deposit():
Step 1 - Start
Step 4 - End
void withdraw():
Step 1 - Start
double getBalance():
Step 1 - Start
Step 3 - End
void display():
Step 1 - Start
Step 3 - End
void addInterest():
Step 1 - Start
Step 3 - call the 'getBalance()' method and store the return value
Step 5 - End
void display():
Step 1 - Start
Step 4 - Check if balance is more than 0. If yes then print the balance else print the appropriate
message
Step 5 - End
Algorithm for Prog6:-
void main():
Step 1 - Start
Step 4 - End
*/
import java.util.*;
double balance;
void deposit()
AccNo++;
balance=0;
balance+=sc.nextDouble();
void withdraw()
balance-=sc.nextDouble();
double getBalance()
return balance;
}
void display()
int rate;
double bal;
void addInterest()
rate=12;
bal= super.getBalance();
bal+=interest;
void display()
super.display();
if(bal>0)
else
System.out.println("Insufficient Balance");
obj.deposit();
obj.withdraw();
obj.addInterest();
obj.display();