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