Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Why am i not getting the 56.5 i need for the test case to passs and get the desired output below:- my code is below

Why am i not getting the 56.5 i need for the test case to passs and get the desired output below:- my code is below so please look and let me know thanks in advance-

1 EasyCheesy 10 20 12 50 3 A_Wha_Dis??? 2 2 1 Sas_Crise_Mi_A_Ded!!! 3 3 1 Ow_Im_Suh_Wikid?!?! 4 2 5

Your Output (stdout)

Priority:Ow_Im_Suh_Wikid?!?! Outstanding:13 Complete:23 Hours Aval:3 Tot. Points:56.498661951556755 

Expected Output

====================== -----TODAY'S PLAN----- ---------------------- Priority:Ow_Im_Suh_Wikid?!?! Assignments:13 Completed:23 Hours Avail:3 Tot. Points:56.5

I think it is due to the formula that i have in the code, this is what i am supposed to have :

Create a public method that evaluates and returns the expected score, using the formula below, which was supplied by a well paid consultant. = . ( + ) (Note: Use the PI attribute of the Math class) Also, report the score to 1 decimal point (important for passing test cases 4 and 5

Create accessor methods for the private variables numAssignments, numComplete, totalPoints, hoursAvailable and highestPriorityItem.

Create an alternative constructor that accepts and sets numAssignments, numComplete, totalPoints, and highestPriorityItem.

Implement a mutator function to set highestPriorityItem

Implement a class to represent an Assignment. i. The Assignment class will privately store information on it's name(String), effort (hours required to complete)(int), the number of resources to be referenced (int), the estimated difficulty(int), and the expected score(double). ii. Create a constructor for a Assignment, that accepts the effort, resources and difficulty. The constructor then evaluates and stores the cost of an assignment, using the formula below, which was supplied by a well paid consultant. (If the formula isunclear, look at the associated PDF which should have a nicer rendering)

= . ( + ( )^/(*sqrt())) ) (Note: Use the PI attribute of the Math class

c.The Assignment has acccessors for all private attributes

Complete the getUrgentAssignment method of the AssignPlan object so that it

a. Creates an Assignment with knowledge of it's name, difficulty, resources and effort

b. Set's the name of the highest priority item to the new assignment

c. Increments the number of outstanding assignments, as well as the number of completed assignments by 1

d. Update the hoursAvailable by subtracting the effortHours (NOTE!!! A full implementation would test if there were sufficient hours available, but you may ignore that concern for this lab)

e. Update the total points by adding the score calculated on the assignment .

Here is the code

import java.io.*; import java.math.*; import java.security.*; import java.lang.Math; import java.text.*; import java.util.*; import java.util.concurrent.*; import java.util.function.*; import java.util.regex.*; import java.util.stream.*; import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.toList;

class AssignPlan { //decalre the private variables private String highPriorityItem=""; private int numAssignment,numComplete,hoursAvailable; private double totalPoints;

//accessor for the private variables private String gethighPriorityItem() { return highPriorityItem; } public int getnumAssignment() { return this.numAssignment; } public int getnumComplete() { return this.numComplete; } public int gethoursAvailable() { return this.hoursAvailable; } public double gettotalPoints() { return this.totalPoints; }

//ToString method for the display ouput public String toString() { return"====================== "+ "-----TODAY'S PLAN----- "+ "---------------------- "+ "Priority:"+gethighPriorityItem()+" "+ "Assignments:"+getnumAssignment()+" "+ "Complete:"+getnumComplete()+" "+ "Hours Aval:"+gethoursAvailable()+" "+ "Tot. Points:"+gettotalPoints()+" "; }

//constructors public AssignPlan() {

}

public AssignPlan(int numAssigns) { numAssignment=numAssigns; } //contructor public AssignPlan(String highPriorityItem,int numAssigns,int numComplete,int hoursAvailable,double totalPoints) { this.highPriorityItem=highPriorityItem; this.numAssignment=numAssigns; this.numComplete=numComplete; this.hoursAvailable=hoursAvailable; this.totalPoints=totalPoints; } //set the priority value public void setPriorityTo(String aname) { this.highPriorityItem=aname; } //method of the handle Assignmet public void handleUrgentAssignment(String name,int efforts,int resources, int difficulty) { Assignment newAssignment=new Assignment(name,efforts,resources,difficulty); this.highPriorityItem=name; this.numAssignment=this.numAssignment+1; this.numComplete=this.numComplete+1; this.hoursAvailable=this.hoursAvailable-efforts; this. totalPoints=this.totalPoints+newAssignment.getScore(); } }

class Assignment { private String name; private int efforts; private int numResources; private int estDifficulty; private double expScore;

//constructor

public Assignment(String name,int efforts,int numResources,int estDifficulty) { this.name=name; this.efforts=efforts; this.numResources=numResources; this.estDifficulty=estDifficulty; this.expScore=0.1* (this.efforts*estDifficulty+Math.pow(this.efforts*numResources)^2/(Math.PI*Math.sqrt(estDifficulty)));

} //accessor methods of private variable public String getName() { return name; } public int getEfforts() { return efforts; } public int getResources() { return numResources; } public int getDifficulty() { return estDifficulty; } public double getScore() { return expScore; } }

public class Tester { public static void main(String[] args) throws IOException { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(bufferedReader.readLine().trim()); for(int test =0; test

String highestPriorityItem = firstMultipleInput[0]; int numOutStanding = Integer.parseInt(firstMultipleInput[1]); int numComplete = Integer.parseInt(firstMultipleInput[2]); int hoursAvailable = Integer.parseInt(firstMultipleInput[3]); double totalPoints = Double.parseDouble(firstMultipleInput[4]); AssignPlan a = new AssignPlan(highestPriorityItem,numOutStanding,numComplete,hoursAvailable,totalPoints); aplan = a; } if (firstMultipleInput.length ==1) { int numOutStanding = Integer.parseInt(firstMultipleInput[0]); AssignPlan a = new AssignPlan(numOutStanding); aplan = a; } String aname = bufferedReader.readLine(); if (aname.length() >0) aplan.setPriorityTo(aname); int assigns = Integer.parseInt(bufferedReader.readLine().trim()); for (int anum=0; anum

if (!(secondInput==null)) { String[] secondMultipleInput = secondInput.replaceAll("\\s+$", "").split(" "); if (secondMultipleInput.length ==4) { String uaname = secondMultipleInput[0]; int effort = Integer.parseInt(secondMultipleInput[1]); int resources = Integer.parseInt(secondMultipleInput[2]); int difficulty = Integer.parseInt(secondMultipleInput[3]); aplan.handleUrgentAssignment(uaname, effort, resources, difficulty);

}

} }//for anum

System.out.println(aplan.toString()); } catch (IOException ex) { throw new RuntimeException(ex); } }

bufferedReader.close(); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions

Question

What are the different mechanisms of regulation of blood pH.

Answered: 1 week ago