0% found this document useful (0 votes)
212 views6 pages

Java Lab Practical File - CSP-279

This document contains a Java program lab file submitted by a student. The file includes 10 experiments to be completed for a Java programming lab course. The first experiment is documented, with the aim to write a program to perform mathematical operations using switch case by taking input from the user. The program code is provided that defines a calculator class with a main method. It takes input of two numbers and an operation, uses a switch case to perform the selected operation of addition, subtraction, division, multiplication or modulus, and prints the output.

Uploaded by

Anshu Singh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
212 views6 pages

Java Lab Practical File - CSP-279

This document contains a Java program lab file submitted by a student. The file includes 10 experiments to be completed for a Java programming lab course. The first experiment is documented, with the aim to write a program to perform mathematical operations using switch case by taking input from the user. The program code is provided that defines a calculator class with a main method. It takes input of two numbers and an operation, uses a switch case to perform the selected operation of addition, subtraction, division, multiplication or modulus, and prints the output.

Uploaded by

Anshu Singh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PRACTICAL FILE

JAVA PROGRAMMING LAB


SUBJECT CODE: CSP-279

Submitted To: Submitted By:


Kulwinder(8770) Name:Anshu

Batch: BE-CSE-10

UID: 18BCS1950

Group: ‘A’
CHANDIGARH UNIVERSITY JAVA LAB / CSP-279

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

Marks
Conduct+Viva+File
[Link]. Name of Experiment Date Re-
(12) (8) (10) marks.

1.

2.

3.

4.

5.

6.

7.

18BCS1950 Page 1
CHANDIGARH UNIVERSITY JAVA LAB / CSP-279

8.

9.

10.

18BCS1950 Page 2
CHANDIGARH UNIVERSITY JAVA LAB / CSP-279

Date: 25thof July,2018


PROGRAM :1

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

PROGRAM:

package calculator;

import [Link];

public class Practise {

public static void main(String[] args) {

Scanner input = new Scanner([Link]);

[Link]("Enter first number");

double a = [Link]();

[Link]("Enter Second number");

double b = [Link]();

[Link]("Enter any following operation");

[Link]("[Link]\[Link]\[Link]\[Link]\[Link]");

int c = [Link]();

switch(c){

case 1:{

double d = a + b;

[Link]("The required addition is :" + d);

break;

case 2:{

18BCS1950 Page 3
CHANDIGARH UNIVERSITY JAVA LAB / CSP-279

double d = a - b;

[Link]("The required substraction is :" + d);

break;

case 3:{

if(b == 0){

[Link]("Wrong input Plz restart the program");

break;

else{

double d = a / b;

[Link]("The required division is :" + d);

break;

case 4:{

double d = a * b;

[Link]("The required multiplication is :" + d);

break;

case 5:{

if(b == 0){

[Link]("Wrong input plz restart the program");

else{

double d = a % b ;

[Link]("The required modulus is :" + d);

18BCS1950 Page 4
CHANDIGARH UNIVERSITY JAVA LAB / CSP-279

break;

default :{

[Link]("Plz restart the program and enter the correct option.");

18BCS1950 Page 5

You might also like