import java.io.*;
class Example{
public static void main(String[] args)
{
try {
method1();
}
catch (Exception e) {
System.out.println(e);
}
}
}
public void method1(int wages, int hours, String name){
Double pay= calculatePay(wages,hours);
PrintWriter PayRoll = new PrintWriter(System.out);
PayRoll.write(wages,hours,pay,name);
PayRoll.flush();
}
public double calculatePay(int wages, int hours){
return double(wages*hours);
}
Write a method to write the name, hours, wages, and pay to a PrintWriter named PayRoll....
IN JAVADesign a Payroll class with the following fields:• name: a String containing the employee's name• idNumber: an int representing the employee's ID number• rate: a double containing the employee's hourly pay rate• hours: an int representing the number of hours this employee has workedThe class should also have the following methods:• Constructor: takes the employee's name and ID number as arguments• Accessors: allow access to all of the fields of the Payroll class• Mutators: let the user assign values...
3. Write Java methods to accomplish each of the following Write a method named simpleAry which accepts and return nothing. It creates an array that can hold ten integers. Fill up each slot of the array with the number 113. Then, display the contents of the array on the screen. You must use a loop to put the values in the array and also to display them. Write a method named sury which accepts an array of type double with...
Create an applet payroll program named CalcPay that allows the user to enter two double valuesand a string namely hours worked, hourly rate and name. After the user enters the rate, hours,and name the program should calculate the gross pay by pressing CALCULATE button. Compute federal withholding tax which is subtracted from gross based on the following table: Hints: (100pts) Use methods as deemed appropriate. 0 to 99.99 6% 100.00 to 299.99 12% 300.00 to 599.99 18% 600.00 and up...
Java Write a class named CheckingAccount containing: An instance variable named balance of type double, initialized to 0. A method named deposit that accepts a parameter of type double. The value of the balance instance variable is increased by the value of the parameter. A method named withdraw that accepts a parameter of type double. The value of the balance instance variable is decreased by the value of the parameter. A method named getBalance that accepts no parameters, returns the...
java coding question: Write a complete program that contains a method named repeat that takes a String as a parameter and returns nothing The method will print (use System.out.println) the input string 5 times. The main method will call the method repeat with the value "Java".
5. Assume pr is a PrintWriter object which was created alreauy, write pria staneiments w prut text file. 12 pts] the following inside the corresponding String name double height; John Smith 6.15 Name: Height: 5. Assume pr is a PrintWriter object which was created alreauy, write pria staneiments w prut text file. 12 pts] the following inside the corresponding String name double height; John Smith 6.15 Name: Height:
I need java code for the following problem. Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that accepts one integer parameter and returns the value raised to the third power as an integer. o Write a method called randominRange that accepts two integer parameters representing a range. The method returns a random integer in the specified range inclusive. 2. o Write a method...
Assume that you have a String "name" attribute in a Java class definition. Write a public method to return this "name" attribute. public String getName() { return name; } 1.) Write a statement that throws an IllegalArgumentException with the error message “Argument cannot be negative”. 2.) The method getValueFromFile is public and returns an int. It accepts no arguments. The method is capable of throwing an IOException and a FileNotFoundException. Write the header for this method.
In Java code Write a complete method name convertFile that accepts a File object representing an input text file and a PrintWriter objects as arguments. The method should read the contents of the input file and change all characters to uppercase and store the results in the output file.
Write a method named avgLength which takes an array of Strings as an input parameter and returns a double. The method should calculate and return the average length of all the strings in the array (in java langauge)