Concept explainers
import java.util.*;
public class Main0 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int totalEmployee = 10;
String [] fname = new String[totalEmployee];
String [] mname = new String[totalEmployee];
String [] lname = new String[totalEmployee];
int [] idNum = new int[totalEmployee];
// Hours Worked Must be Between 0 and 60 Hours
int [] workHour = new int[totalEmployee];
// Rate per Hour Must be Between $15.00 and $35.00
int [] ratePerHour = new int[totalEmployee];
// add Data in the array
for (int i=0; i<totalEmployee; i++){
// First Name Input
System.out.println("Enter First Name");
fname[i] = sc.next();
// Middle Name Input
System.out.println("Enter Middle Name");
mname[i] = sc.next();
// Last Name Input
System.out.println("Enter Last Name");
lname[i] = sc.next();
// Id Number Input
System.out.println("Enter Id number");
idNum[i] = sc.nextInt();
// Hours Worked Input
System.out.println("Enter Hours worked");
workHour[i] = sc.nextInt();
// Rate Per Hour Input
System.out.println("Enter Rate Per Hour");
ratePerHour[i] = sc.nextInt();
}
// State Tax Percentage
int state_tax_p = 7;
// Fed Tax Percentage
int fed_tax_p = 15;
// Gross Array Created
double [] gross = new double[totalEmployee];
for (int i=0; i<totalEmployee; i++){
if(workHour[i] > 0){
if(ratePerHour[i] >= 15 && ratePerHour[i] <= 35){
if(workHour[i] < 40){
gross[i] = workHour[i] * ratePerHour[i];
}
else{
gross[i] = (40 * ratePerHour[i] + (workHour[i] - 40) * ratePerHour[i] * 1.5);
}
}
else{
System.out.println("Please Enter Your Number Between 15 to 35");
}
}
else{
System.out.println("Please Enter Greater Number");
}
}
// Stored State Tax, Fed Tax and Net in the array for 10 Employee
double [] state_tax = new double[totalEmployee];
double [] fed_tax = new double[totalEmployee];
double [] net = new double[totalEmployee];
for(int i=0; i<totalEmployee; i++){
state_tax[i] = gross[i] * state_tax_p;
fed_tax[i] = gross[i] * fed_tax_p;
net[i] = gross[i] - (state_tax[i] + fed_tax[i]);
}
// Print All The Data With Table Format
System.out.printf("%-15s %-15s %-15s %-15s %-15s %-15s %-15s %-15s %-15s\n", "Last Name", "First Name", "MI Id", "Rate Per Hour", "Hours Worked", "State Tax", "Fed tax", "Gross", "Net");
for(int i=0; i<totalEmployee; i++) {
System.out.printf("%-15s %-15s %-15d %-15d %-15d %-15f %-15f %-15f %-15f\n", lname[i], fname[i], idNum[i], ratePerHour[i], workHour[i], state_tax[i], fed_tax[i], gross[i], net[i]);
}
}
}
Pseudo Code
Step by stepSolved in 2 steps
- import java.util.*; public class Watersort { Character top = null; // create constants for colors static Character red= 'r'; static Character blue = 'b'; static Character yellow= 'g'; // Bottles declaratio public static void showAll( StackAsMyArrayList bottles[]) { for (int i = 0; i<=4; i++) { System.out.println("Bottle "+ i+ ": " + bottles[i]); } } public static void main(String args[]) { //create the bottle StackAsMyArrayList bottleONE = new StackAsMyArrayList<Character>(); System.out.println("\nbottleONE:"+ bottleONE+ " size:" + bottleONE.getStackSize()+" uniform? "+ bottleONE.checkStackUniform()); bottleONE.push(red);…arrow_forwardJAVA CODE: check outputarrow_forwardO New 1. public class ArrayProcessingl { ArrayProcessinglJeva"o public static void main(String[] args) { java.util.Scanner input - new java.util.Scanner(System. in); System.out.println("Enter the size of the array to be created: "); Int size - input.nextInt(); 2 6. //(1) Question to ponder: Can you create an array that can store data of severpl different data types? //Answer: No. /(2) Question to ponder: Once an array is created, can its size be changed? //Answer: No. 10 11 12 //(3) TODO: Replace null wdth cod to create an int array that has the size the user just entered. int[] mylist - null; /(4) TODO: Write a loop after the prompt to get user enter values that will be stored in the array System.out.println("Enter + mylist. length + 13 14 15 16 17 values: "): 18 19 //(5) TODO: Replace e below with the first array element System.out.println("The first array element is+ 0); 20 21 22 23 24 25 26 } /end of class ArrayProcessing //(6) TODO: Fix the index to get the last array element…arrow_forward
- import java.util.Scanner; public class TriangleArea { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); Triangle triangle1 = new Triangle(); Triangle triangle2 = new Triangle(); // TODO: Read and set base and height for triangle1 (use setBase() and setHeight()) // TODO: Read and set base and height for triangle2 (use setBase() and setHeight()) System.out.println("Triangle with smaller area:"); // TODO: Determine smaller triangle (use getArea()) // and output smaller triangle's info (use printInfo()) }} public class Triangle { private double base; private double height; public void setBase(double userBase){ base = userBase; } public void setHeight(double userHeight) { height = userHeight; } public double getArea() { double area = 0.5 * base * height; return area; } public void printInfo() { System.out.printf("Base:…arrow_forwardimport java.util.Scanner; public class StateInfo { /* Your code goes here */ public static void main(String[] args) { Scanner scnr = new Scanner(System.in); String stateCode; String stateName; stateCode = scnr.next(); stateName = scnr.next(); printStateInfo(stateCode, stateName); }}arrow_forwardimport java.util.Objects;class CovidVariant { String Name; String Unique_code; CovidVariant left, right; public CovidVariant(String name, String code) { this.Name = name; this.Unique_code = code; left = right = null; }}class VariantCollection { private boolean compare_code(String code, String code_2) { int year = Integer.parseInt(code.substring(0, 2)); int month = Integer.parseInt(code.substring(2, 4)); int date = Integer.parseInt(code.substring(4, 6)); int year_2 = Integer.parseInt(code_2.substring(0, 2)); int month_2 = Integer.parseInt(code_2.substring(2, 4)); int date_2 = Integer.parseInt(code_2.substring(4, 6)); if (year == year_2) { if (month == month_2) { if (date > date_2) { return true; } else { return false; } } else if (month > month_2) { return true; }…arrow_forward
- import java.util.Scanner; public class SMSTranslator { public static void main(String[] args) { Scanner console = new Scanner(System.in); String getAbbreviation = ""; { String BFF = "The translation is Best Friends FOREVER!!! :-)"; String BTE = "The translation is Blew The Exam :-("; String STT = "The translation is Spill The Tea ;-)"; getAbbreviation = console.next(); System.out.print("Enter SMS abbreviation: "); public Class.decode Abbreviation(console) if (getAbbreviation.compareTo("BFF") == 0) { System.out.println(BFF); } else if (getAbbreviation.compareTo("BTE") == 0) { System.out.println(BTE); } else if (getAbbreviation .compareTo("STT") == 0) { System.out.println(STT); // if input is out of dictonary } else{ System.out.println("The translation is…arrow_forwardimport java.util.Scanner; public class CharMatch { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); String userString; char charToFind; int strIndex; userString = scnr.nextLine(); charToFind = scnr.next().charAt(0); strIndex = scnr.nextInt(); /* Your code goes here */ }}arrow_forwardWrite a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending when the user enters "Quit", "quit", or "q" for the line of text. Ex: If the input is: Hello there Неу quit the output is: ereht olleH yeHarrow_forward
- public class Main { static int findPosSum(int A[], int N) { if (N <= 0) return 0; { if(A[N-1]>0) return (findPosSum(A, N - 1) + A[N - 1]); else return findPosSum(A, N - 1); } } public static void main(String[] args) { int demo[] = { 11, -22, 33, -4, 25,12 }; System.out.println(findPosSum(demo, demo.length)); } } Consider the recursive function you wrote in the previous problem. Suppose the initial call to the function has an array of N elements, how many recursive calls will be made? How many statements are executed in each call? What is the total number of statements executed for all recursive calls? What is the big O for this function?arrow_forwardpublic class Ex08FanTest { public static void main (String[] args){ Ex08Fan fan1= new Ex08Fan(); Ex08Fan fan2= new Ex08Fan(); fan1.setOn(true); fan1.setSpeed(3); fan1.setRadius(10); fan1.setColor("yellow"); fan2.setOn(true); fan2.setSpeed(2); fan2.setRadius(5); fan2.setColor("blue"); fan2.setOn(false); System.out.println("Fan 1:\n" + fan1.toString()); System.out.println("\nFan 2:\n" + fan2.toString()); }}arrow_forwardGiven string inputStr on one line and integers idx1 and idx2 on a second line, output "Match found" if the character at index idx1 of inputStr is equal to the character at index idx2. Otherwise, output "Match not found". End with a newline. Ex: If the input is: eerie 4 1 then the output is: Match found Note: Assume the length of string inputStr is greater than or equal to both idx1 and idx2.arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY