What's new

Comment for Chegg answers

Status
Not open for further replies.
1)deadlock:

ex1) two teams fighting for playing volleyball in school premises,where one team1 own the ball and team2 own the net .team1 waiting until team2 leave the net and team2 waiting until team1 leave the ball.

2)starvation:

ex1)

Kid waiting for remote control when his parents watching the TV.In this scenario remote control always in the hans of parents.Kid has to wait for a longtime.

3)race

ex1)

in a hotel 45 tables are available and customers have to reserve them through phone calls, receptionists will answer the call,customer's whose call answerd first by receptionist will get a table,even though customer had tried the call earlier while receptionist on other call can't get the table.
 
You do not have permission to view the full content of this post. Log in or register now.

Patulong po
1607464761658.png
 

Attachments

import java.util.Scanner;
public class GrossPay {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Asking the user to enter employee name
System.out.print("Enter employee name: ");
String name = sc.nextLine();
// Asking for full time or part time
System.out.print("Press F for Full Time or P for Part Time: ");
char choice = sc.next().charAt(0);
if(choice == 'P') {
System.out.println("--- Part Time Employee ---");
System.out.print("Enter rate per hour: "); // Asking the user to enter rate per hour
double rate_per_hour = sc.nextDouble();
System.out.print("Enter no. of hours worked: "); // Asking the user to enter no of hours worked
int hours_worked = sc.nextInt();
System.out.print("Enter no. of overtime: "); // Asking the user to enter no of over time
int overtime = sc.nextInt();
System.out.println("\n-------------------------------------");
System.out.println("Employee Name: "+name);
double basic_pay;
basic_pay = rate_per_hour * hours_worked; // Calculating basic pay
System.out.println("Basic Pay:\t"+basic_pay);
double overtime_pay;
overtime_pay = (rate_per_hour + (rate_per_hour * 0.25)) * overtime; // Calculating overtime play
System.out.println("Overtime Pay:\t"+overtime_pay);
System.out.println("\n-------------------------------------");
double gross_pay;
gross_pay = basic_pay + overtime_pay; //Calculating gross pay
System.out.println("Gross Pay:\t"+gross_pay);
}
}
}
 
Java Code Snippet :

import java.util.Scanner;

public class Main
{
public static void main(String[] args) {
// Scanner object: input
Scanner input = new Scanner(System.in);

// declaring various arrays
String names[] = new String[3];
String initials[] = new String[6];
String usernames[] = new String[6];

// asking for first names
System.out.println("Enter three first names: ");
for(int i=0; i<3; i++)
names = input.next();

System.out.println();

// dislaying combinations
// and storing initals and usernames
int count = 0 ;
for (int i=0; i<3; i++)
{
for (int j=0; j<3; j++)
{
if ( !names.equals(names[j]))
{
System.out.println(names + " " + names[j]);
initials[count] = (names.substring(0,1)+names[j].substring(0,1));
usernames[count] = (names.toLowerCase()+"_"+names[j].toLowerCase());

// count = count + 1
count++;
}

}
}

System.out.print("\nSelect a name (by entering 1 to 6): ");

// asking from user to choose a combination
int choice = input.nextInt();

// displaying initials and username
System.out.println("Initials: " + initials[choice-1]);
System.out.println("Suggested username: " + usernames[choice-1]);


}
}
 
Status
Not open for further replies.

Similar threads

Back
Top