i need the same code but using inheritance and abstract class at least build a super abstract class , a sub class and build a main to run the code with javafx JOptionpane please if you can not answer the write code don't answer (Thank you)
import javax.swing.JOptionPane;
public class CollegeAdmission{
public static void main(String args[]) {
String testScoreString;
String classRankString;
int testScore;
int classRank;
testScoreString = JOptionPane.showInputDialog("Enter test score:
");
testScore = Integer.parseInt(testScoreString);
classRankString = JOptionPane.showInputDialog("Enter class rank:
");
classRank = Integer.parseInt(classRankString);
if( testScore >= 90 ) {
if( classRank >= 25) {
System.out.println("Accept"); }
else
System.out.println("Reject");
}
else {
if( testScore >= 80 ) {
if( classRank >= 50 )
System.out.println("Accept");
else
System.out.println("Reject"); }
else {
if( testScore >= 70 ) {
if( classRank >=75 )
System.out.println("Accept");
else
System.out.println("Reject");
}
else
System.out.println("Reject"); } } }
}
import javax.swing.JOptionPane;
//Accepter is abstract type class we cannot directly initialize it
by the main method
abstract class Accepter{
/*isAccept function take testscore and class rank as
parameter and
check the condition is acceptable or not if else
codition are same
like your code*/
void isAccept(int testScore,int classRank){
if( testScore >= 90 ) {
if( classRank >= 25) {
System.out.println("Accept");
}
else
System.out.println("Reject");
}
else {
if( testScore >= 80 )
{
if( classRank >= 50
)
System.out.println("Accept");
else
System.out.println("Reject");
}
else {
if( testScore >= 70 ) {
if( classRank
>=75 )
System.out.println("Accept");
else
System.out.println("Reject"); }
else
System.out.println("Reject"); } }
}
}
//here we are inheriting Accepter class in your CollegeAdmission
class
public class CollegeAdmission extends Accepter{
//all code is same as your
public static void main(String args[]) {
String testScoreString;
String classRankString;
int testScore;
int classRank;
testScoreString = JOptionPane.showInputDialog("Enter test score:
");
testScore = Integer.parseInt(testScoreString);
classRankString = JOptionPane.showInputDialog("Enter class rank:
");
classRank = Integer.parseInt(classRankString);
//creating a new object of CollegeAdmission class by using it we
call the Accepter class method
CollegeAdmission obj = new CollegeAdmission();
obj.isAccept(testScore,classRank);//calling method
}
}
Screenshot of code
i need the same code but using inheritance and abstract class at least build a super...
Please help, Array does not print properly. I need to print out the 8 class numbers entered by the user ! Java only using J option pane, you cannot use ulti or anything else only J option pane Program compiles but does not print the array correctly! import javax.swing.JOptionPane; public class programtrial { public static void main(String[] args) { int newclass = 0; int countclass = 0; final int class_Max = 8; int[] classarray =...
Hi, for my Java class I have built a number guessing game. I need to separate my code into two classes and incorporate a try-catch statement. Any help would be appreciated! Here is my code. import javax.swing.JOptionPane; import javax.swing.UIManager; import java.awt.Color; import java.awt.color.*; import java.util.Random; public class game { public static void main (String [] args) { UIManager.put("OptionPane.backround", Color.white); UIManager.put("Pandelbackround", Color.white); UIManager.put("Button.background", Color.white); Random nextRandom = new Random(); int randomNum = nextRandom.nextInt(1000); boolean playerCorrect = false; String keyboardInput; int playerGuess...
This is the source code: Please incorporate the Exception Handling import javax.swing.JOptionPane; import java.awt.*; public class GuessingGame { public static void main(String[] args) { int computerNumber = (int) (Math.random() * 10 + 1); System.out.println("The correct guess would be " + computerNumber); int userAnswer = 0; int count = 0; while (computerNumber != userAnswer) { count++; String response = JOptionPane.showInputDialog(null, "Enter a guess between 1 and 10"); userAnswer = Integer.parseInt(response); String result = null; if (userAnswer == computerNumber) { result =...
I need help with adding comments to my code and I need a uml diagram for it. PLs help.... Zipcodeproject.java package zipcodesproject; import java.util.Scanner; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class Zipcodesproject { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner input=new Scanner(System.in); BufferedReader reader; int code; String state,town; ziplist listOFCodes=new ziplist(); try { reader = new BufferedReader(new FileReader("C:UsersJayDesktopzipcodes.txt")); String line = reader.readLine(); while (line != null) { code=Integer.parseInt(line); line =...
Java Branches code not working please HELP!! I am trying to build this class that will ask for an ingredient, and the number of cups of the ingredient. It should then branch into an if/else branch off to verify that the number entered is valid and that it is within range. Once that branch completes it should then continue on to ask for the calories per cup, and then calculate total calories. Once I get it to enter the branch...
Identify a logical error in the following code and fix it. public class test1 { public static void main(String[] args){ int total; float avg; int a, b, c; a=10; b=5; c=2; total=a+b+c; avg=total/3; System.out.println("Average: "+avg); } } Answer: Write the output of the program below. import java.util.Scanner; public class test2 { public static void main(String[] arg){ int psid; String name; Scanner input=new Scanner(System.in); System.out.println("Enter your PSID"); psid=input.nextInt(); System.out.println("Enter your...
Step 4: Add code that discards any extra entries at the propmt that asks if you want to enter another score. Notes from professor: For Step 4, add a loop that will validate the response for the prompt question: "Enter another test score? (y/n): " This loop must only accept the single letters of ‘y’ or ‘n’ (upper case is okay). I suggest that you put this loop inside the loop that already determines if the program should collect...
Write an application that displays a series of at least five student ID numbers (that you have stored in an array) and asks the user to enter a numeric test score for the student. Create a ScoreException class, and throw a ScoreException for the class if the user does not enter a valid score (less than or equal to 100). Catch the ScoreException, display the message Score over 100, and then store a 0 for the student’s score. At the...
How to build Java test class? I am supposed to create both a recipe class, and then a class tester to test the recipe class. Below is what I have for the recipe class, but I have no idea what/or how I am supposed to go about creating the test class. Am I supposed to somehow call the recipe class within the test class? if so, how? Thanks in advance! This is my recipe class: package steppingstone5_recipe; /** * *...
use the same code. but the code needs some modifications. so use this same code and modify it and provide a output Java Program to Implement Merge Sort import java.util.Scanner Class MergeSort public class MergeSort Merge Sort function / public static yoid sortfintfl a, int low, int high) int N-high-low; if (N1) return; int mid- low +N/2; Il recursively sort sort(a, low, mid); sort(a, mid, high); I/ merge two sorted subarrays int] temp new int[N]; int i- low, j-mid; for...