Answer-1
public class Reservation {
int ticketID;
String name;
String source;
String destination;
Reservation() {
ticketID = 80;
name ="Harry";
source = "Chicago"
destination = "Dallas";
}
public void showTicket () {
System.out.println("The Ticket ID is "+ ticketID);
System.out.println("The Passenger Name is "+ name);
System.out.println("The Sourse is" + sourse);
System.out.println("The Destination is" + Destination);
System.out.println("\nChoose the option: ");
public static void main(String[] args) {
Reservation g = new Reservation();
g.showTicket();
}
}
Answer-2
public class EmployeeDetails {
public void showMenue () {
int option;
System.out.println("------------Menu--------");
System.out.println("1. Enter Data");
System.out.println("2. Display Data");
System.out.println("3. Exit");
System.out.println("\nChoose the option: ");
Option = 2;
switch (option) {
case 1:
enterData();
break;
case2:
DisplayData();
break;
case3:
exitMenue();
break;
defalt:
System.out.println("Incorrect menu option");
showMenu();
break;
}
}
public void enterData() {
System.out.println("enterData method is invoked");
}
public void enterData() {
System.out.println("displayData method is invoked");
}
public void enterData() {
System.out.println("exitMenu method is invoked");
System.exit(0);
}
public static void main(String[] args) {
EmployeeDetails obj = new EmployeeDetails();
obj.showMenu();
}
}
Answer-3
class Grocery{
private int weight;
String productName;
double price;
public Grocery()
{
weight=4;
productName="Sugar";
price=6;
}
public void weightAdd()
{
weight +=3;
}
public void weightRemove()
{
weight -=3;
}
public void checkWeight()
{
System.out.println(+weight);
}
public static void main(String args[])
{
Grocery g=newGrocery();
System.out.println("The Current weight is");
g.checkWeight();
System.out.println("The wight after addition is");
g.weightAdd();
g.checkWeight();
System.out.println("The wight after substraction is");
g.weight Remove();
g.checkWeight();
}
}
Answer-4
public class employeerecord
string employeeDetails [] [] = new String [1] [7];
public void storeData() {
employeeDeatils [0] [0] = "A101";
employeeDeatils [0] [1] = "john mathew";
employeeDetails [0] [2] = "admin";
employeeDetails [0] [3] = "manager";
employeeDetails [0] [4] = "05/04/1998";
employeeDetails [0] [5] = "11/09/1997";
employeeDetails [0] [6] = "married";
}
public void displayData() {
system.out.println ("Employee Details:");
for ( int i = 0; i < employeeDetails,length;
for ( int j = 0; j < employeeDetails[i].length; j++ {
system.out.println(employeeDetails[i] [j] );
}
}
}
public static void main (String [] args) {
EmployeeRecord obj = new EmployeeRecord();
obj.storeData();
obj.displayData();
}
}
Answer-5
public class VowelChecker
{
public static void main(String args[])
{
String input;
switch(input)
{
case"a":
case"A":
}
}
}
Answer-6
No comments:
Post a Comment