Professional Documents
Culture Documents
New DOCX Document
New DOCX Document
New DOCX Document
package lab7;
}
class myu
{public static void main(String[]args)
{
movie s1=new movie(1,"demon");
action s2=new action(2,"attack");
drama s3=new drama(3,"naruto");
System.out.println("movie late fee"+s1.calcfee(5));
System.out.println("action late fee:"+s2.calcfee(5));
System.out.println("drama late fee:"+s3.calcfee(5));
}
}
-------------------------------------------------------5------------------------------------------------
class Simple {
int num1;
int num2;
public Account() {
balance = 0.0;
}
account1.deposit(5000);
account1.withdraw(2000);
account2.setBalance(70000);
account2.deposit(10000);
account2.withdraw(5000);
account2.showBalance();
}
}
QNO2
class Student {
String name;
String section;
int rollNumber;
int matricMarks;
// Constructor
public Student(String name, String section, int rollNumber) {
this.name = name;
this.section = section;
this.rollNumber = rollNumber;
this.matricMarks = 0;
}
student1.setMatricMarks(85);
student2.setMatricMarks(90);
QNO4
package workk;
import java.util.Scanner;
public class racingcar {
private String model;
private String color;
private int speed;
private int score;
racingcar()
{model="unknown";
color="unknown";
speed=00;
score=00;
}
racingcar(String model,String color,int speed,int score)
{this.color=color;
this.model=model;
this.score=score;
this.speed=speed;
}
public void setmodel(String model)
{this.model=model;}
public String getmodel()
{return model;}
public void setcolor(String color)
{this.color=color;
}
public String getcolor()
{return color;
}
public void setspeed(int speed)
{this.speed=speed;
}
public int getspeed()
{return speed;}
public void setscore(int score)
{
this.score=score;}
public int getscore()
{return score;
}
public void turnleft(int steps)
{System.out.println("turn left"+steps+"steps");
score+=steps;
}
public void turnright(int steps)
{System.out.println("turn left:"+steps+"steps");
score-=steps;
}
void display()
{System.out.println("model is:"+model);
System.out.println("color is:"+color);
System.out.println("speed is:"+speed);
System.out.println("score is:"+score);
}
}
class mywork
{public static void main(String[]args)
{Scanner dd=new Scanner(System.in);
System.out.println("enter model:");
String model=dd.nextLine();
System.out.println("enter color:");
String color=dd.nextLine();
System.out.println("enter speed:");
int speed=dd.nextInt();
System.out.println("enter score:");
int score=dd.nextInt();
racingcar s1=new racingcar(model,color,speed,score);
System.out.println("ATTRIBUTES:");
s1.display();
System.out.println("PERFORMANCE");
s1.turnleft(5);
s1.turnright(10);
System.out.println("performace is:");
s1.display();
}
}
--------------------------------------------------------------------------LAB 5--------------------------------------
QNO1
class University {
private String universityName;
private String location;
QNO2
class Student {
private String name;
private int rollNumber;
private double attendance;
private String section;
QNO3
class Car {
private String model;
private int manufacturingYear;
private String color;
private int fuelAverage;
myCar.setFuelAverage(15);
myCar.displayInfo();
}
}
QNO4
import java.util.Scanner;
class Car {
private String model;
private int manufacturingYear;
private String color;
private int fuelAverage;
--------------------------------------------------------------------------------LAB3----------------------------------------------
QNO1
import java.util.Scanner;
class Student {
private String name;
private double percentage;
scanner.close();
}
}
QNO2
import java.util.Scanner;
class Student {
private double attendance;
private double quizMarks;
private double assignmentMarks;
if (student.isEligibleForExam()) {
System.out.println("The student is eligible to sit in the final exam.");
} else {
System.out.println("The student is not eligible to sit in the final
exam.");
}
scanner.close();
}
}
QNO3
import java.util.Scanner;
class Product {
private String name;
private double price;
private int quantity;
class BillCalculator {
private Product[] products;
private String cardCategory;
return totalBill;
}
switch (cardCategory.toUpperCase()) {
case "A":
discountPercentage = 50;
break;
case "B":
discountPercentage = 30;
break;
case "C":
discountPercentage = 15;
break;
default:
System.out.println("Invalid card category. No discount applied.");
}
scanner.close();
}
}