import java.util.Scanner; public class StudentNamesSorter { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); // Get the number of students System.out.print(“Enter the number of students: “); int numberOfStudents = scanner.nextInt(); scanner.nextLine(); // Consume the newline // Array to store student names String[][] studentNames = new String[numberOfStudents][]; // Get student names from the…
import java.util.Scanner; public class MatrixOperations { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println(“Enter the number of rows and columns of the first matrix:”); int rows1 = scanner.nextInt(); int cols1 = scanner.nextInt(); int[][] matrix1 = new int[rows1][cols1]; System.out.println(“Enter the elements of the first matrix:”); for (int i = 0; i <…
public class BooleanOperations { // Method for AND operation public static boolean andOperation(boolean a, boolean b) { return a && b; } // Method for OR operation public static boolean orOperation(boolean a, boolean b) { return a || b; } // Method for XOR operation public static boolean xorOperation(boolean a, boolean b) { return a…
import java.time.LocalDate; import java.time.format.DateTimeFormatter; public class Date { private int day; private int month; private int year; public Date(int day, int month, int year) { this.day = day; this.month = month; this.year = year; } public void addDays(int days) { LocalDate currentDate = LocalDate.of(year, month, day); LocalDate newDate = currentDate.plusDays(days); this.day = newDate.getDayOfMonth(); this.month =…
Students are required to develop the following type of programs in Java language with internaldocumentation:1. Write a Class Date that takes day, month, and year while creating an object of this class. Find a new datewhen the number of days is given.2. Write a program to implement Boolean AND, OR, XOR, and NOT operations.3. Write…
import java.util.Scanner; class A { public static void main(String args[]) { int a; char b; double d; long e; byte f; boolean g; String h; a=10; b=’e’; d=23.1; e=44; f=11; g=true; h=”aaa”; System.out.println(a); System.out.println(b); System.out.println(d); System.out.println(e); System.out.println(f); System.out.println(g); System.out.println(h); } }
import java.util.Scanner; class A { public static void main(String args[]) { double d; System.out.println(“Enter a Number”); Scanner inp=new Scanner(System.in); d=inp.nextDouble(); System.out.println(d); } }
class Add { public static void main(String args[]) { int a,b,c; a=19; n=20; c=a+b; System.out.println(“Sum ”+c); } }
class A { public static void main(String args[]) { System.out.println(“Hello World”); } }