0% found this document useful (0 votes)
70 views

Java P

fd
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views

Java P

fd
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

PRACTICAL FILE

JAVA PROGRAMMING LAB


SUBJECT CODE: CSP-279

Submitted To: Submitted By:


Er. Rubleen ma’am Name:Pooja Yadav

Batch: BE-CSE-10

UID: 18BCS2014

Group: ‘B’
JAVA PROGRAMMING LAB

Lab Index
Name: Pooja Yadav UID:18BCS2014 Class/Section: 18-CSE-10
Subject Name: Java Lab Subject Code: CSP-279 Branch: CSE

Marks
Conduct+Viva+File
S.No. Name of Experiment Date Remarks.
(12) (8) (10)

1.

2.

3.

4.

5.

6.

7.

8.

18BCS2014 Page 7
JAVA PROGRAMMING LAB

9.

10.

18BCS2014 Page 7
JAVA PROGRAMMING LAB

Date: 30thof July,2018


PROGRAM :1

AIM: Write a program to perform mathematical operations using switch case taking
input from the user.

PROGRAM:
import java.util.Scanner;

import java.io.*;

public class Main

public static void main(String[] args)

Scanner sc = new Scanner(System.in);

System.out.print("Enter two numbers: ");

double first = sc.nextDouble();

double second = sc.nextDouble();

System.out.print("Enter an operator (+, -, *, /): ");

char operator = sc.next().charAt(0);

double result;

switch(operator)

case '+':

result = first + second;

break;

case '-':

result = first - second;

break;

case '*':

18BCS2014 Page 7
JAVA PROGRAMMING LAB

result = first * second;

break;

case '/':

result = first / second;

break;

default:

System.out.printf("Error! operator is not correct");

return;

System.out.printf("%.1f %c %.1f = %.1f", first, operator, second, result);

OUTPUT:

18BCS2014 Page 7
JAVA PROGRAMMING LAB

Date: 20 of August,2019
PROGRAM : 3

AIM: Write a program in java to show details of Vehicle-Car class using Inheritance as Car
is a Vehicle.

import java.io.*;

class vehicle

public void vehicles()

System.out.println("This is a method called from parent class");

System.out.println("Vehicles can be a Car , Motorbike etc...");

class car extends vehicle

public void cars()

System.out.println("This is a method called from child class");

System.out.println("Here it is Car.");

System.out.println("Name of car is Aventador");

System.out.println("It is a sports car");

void display()

{
18BCS2014 Page 7
JAVA PROGRAMMING LAB

System.out.println("This again a method called from parent class");

System.out.println("Car number of the car is: 2308");

} }

public class Main

{ public static void main(String[] args)

car obj = new car();

obj.vehicles();

obj.cars();

obj.display();

OUTPUT:

18BCS2014 Page 7
JAVA PROGRAMMING LAB

18BCS2014 Page 7
JAVA PROGRAMMING LAB

18BCS2014 Page 7

You might also like