Need a help about these two Java homework with step by step definition 2. Define
ID: 3571985 • Letter: N
Question
Need a help about these two Java homework with step by step definition2. Define an abstract class named Employee. Define following classes to inherit the abstract class, a) Boss class, indicate the boss who get paid with a fixed salary without considering working hours; b) CommissionWork class, indicate the workers who some basic salary and floating wages according to sales: c Pieceworker class, indicate those who are paid according to the numbers of products; Define above four classes, to implement the abstract methods declared in the abstract class -getPaido method without any parameter but have a return value for total salary, and, -display0 method for output the information about the employee. And define another class with main method (also called test class or driven class), to test the methods defined.
Explanation / Answer
import java.util.Scanner;
public class ReadStringClass {
private Scanner scanner;
public ReadStringClass() {
// TODO Auto-generated constructor stub
scanner = new Scanner(System.in);
}
public String readString() {
String input;
System.out.print("Please input a string: ");
input = scanner.nextLine();
return input;
}
}
public class EstimateStringClass {
private int numberOfUpperCase;
private int numberOfLowerCase;
/**
* @param str
*/
public void estimateString(String str) {
numberOfLowerCase = 0;
numberOfUpperCase = 0;
for (int i = 0; i < str.length(); i++) {
if (Character.isUpperCase(str.charAt(i)))
numberOfUpperCase++;
else if (Character.isLowerCase(str.charAt(i)))
numberOfLowerCase++;
}
}
/**
*
*/
public void printResults() {
System.out.println("Number of Uppercase: " + numberOfUpperCase);
System.out.println("Number of Lowercase: " + numberOfLowerCase);
}
}
public class Question3 {
public static void main(String[] args) {
ReadStringClass readStringClass = new ReadStringClass();
String str = readStringClass.readString();
EstimateStringClass estimateStringClass = new EstimateStringClass();
estimateStringClass.estimateString(str);
estimateStringClass.printResults();
}
}
OUTPUT:
Please input a string: Hai this Srinivas
Number of Uppercase: 2
Number of Lowercase: 13
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.