0% found this document useful (0 votes)
24 views2 pages

Sanjog Jaiya - Lab 4

The document contains 3 code snippets that demonstrate different Java programming concepts: 1. A basic calculator program that takes user input for two numbers and performs addition, subtraction, multiplication and division operations on them. 2. A program that initializes a 2D array to store student marks, assigns values to some elements and prints the sum of those elements along with calculating the total score out of 50. 3. A program that prints a welcome message in the form of a word "WELCOME" split across multiple lines.

Uploaded by

jaiyasanjog16
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)
24 views2 pages

Sanjog Jaiya - Lab 4

The document contains 3 code snippets that demonstrate different Java programming concepts: 1. A basic calculator program that takes user input for two numbers and performs addition, subtraction, multiplication and division operations on them. 2. A program that initializes a 2D array to store student marks, assigns values to some elements and prints the sum of those elements along with calculating the total score out of 50. 3. A program that prints a welcome message in the form of a word "WELCOME" split across multiple lines.

Uploaded by

jaiyasanjog16
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
You are on page 1/ 2

Question 1:

import java.util.Scanner;

public class Calculator


{

public static void main(String[] args) {


Scanner in = new Scanner(System.in);

System.out.print("Input first number: ");


int num1 = in.nextInt();

System.out.print("Input second number: ");


int num2 = in.nextInt();

System.out.println(num1 + " + " + num2 + " = " +


(num1 + num2));

System.out.println(num1 + " - " + num2 + " = " +


(num1 - num2));

System.out.println(num1 + " x " + num2 + " = " +


(num1 * num2));

System.out.println(num1 + " / " + num2 + " = " +


(num1 / num2));

Question 2

public class Question2 {


public static void main(String []args){
int marks[][] = new int[3][4];

marks[8][10]=80;
marks[9][10]=90;
marks[10][10]=100;
marks[6][10]=60;
marks[7][10]=70;
System.out.println( marks[8][10] +"" +marks[9][10] +"" + marks[10][10] +"" +
marks[6][10] +"" + marks[7][10] +"");
int a = 80;
int b = 90;
int c = 100;
int d = 60;
int e = 70;
System.out.println("The score out of 50" + (a+b+c+d+e)*0.50));
}
}

Question 3
public class Question3
{
public static void main(String args[])
{
System.out.println("W");
System.out.println("E L");
System.out.println("C O M");
System.out.println("E T O A");

}
}

You might also like