Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The assignment can be found here:http://people.bridgewater.edu/~vcapacci/Classes

ID: 3531212 • Letter: T

Question

The assignment can be found here:http://people.bridgewater.edu/~vcapacci/Classes/2013-Sp-CSCI200/PAs/PA2/pa2.html


The driver program, (http://people.bridgewater.edu/~vcapacci/Classes/2013-Sp-CSCI200/PAs/PA2/ToolkitTester.java), contains a main method that will create a new Toolkit object, run eachof its methods, and produce output that indicates whether your methods conformed to the expected behavior. Method headers containing the name of the method, input parameters, and return type are found in the file,( http://people.bridgewater.edu/~vcapacci/Classes/2013-Sp-CSCI200/PAs/PA2/Toolkit.java).

Explanation / Answer

import java.util.Scanner;

public class Toolkit
{
public int getInteger(Scanner kb, String prompt, String error, int iValue)
{
int result;
System.out.println(prompt);
if(kb.hasNextInt())
{
result = kb.nextInt();
}
else
{
System.out.println(error);
result = iValue;
}
return result;

}
public double getDouble(Scanner scan, String prompt, String error, double dValue) {
double result;
System.out.println(prompt);
if(scan.hasNextInt())
{
result = scan.nextInt();
}
else
{
System.out.println(error);
result = dValue;
}
return result;
}
// Like get integer above - but with doubles

public boolean isHeavy(char check, char test, boolean inclusive){
boolean heavy = false;
if(check > test) {
heavy = true;
}
else if(check < test) {
heavy = false;
}
else {
if(inclusive) {
heavy = true;
}
else {
heavy = false;
}
}
return heavy;
}
// is Heavy is checks to see if check is higher in the alphabet (is Heavier) than test.
// the boolean inclusive determines if the end points are included
// if inclusive is false, A is not Heavier than A
// if inclusive is true, A is Heavier than B

public boolean isInRange(int check, int low, int high, boolean inclusive){
boolean inrange = false;
if(check > low && check < high) {
inrange = true;
}

else {
if(inclusive && (check == low | check ==high)) {
inrange = true;
}
else {
inrange = false;
}

}
return inrange;
}
// checks to see if check is in the range of low and high
// the boolean inclusive determines if the end points are included
// if inclusive is false, 1 is not in the range of 1 and 10
// if inclusive is true, 1 is in the range of 1 and 10

public boolean isInRange(double check, double low, double high, boolean inclusive){
boolean inrange = false;
if(check > low && check < high) {
inrange = true;
}

else {
if(inclusive && (check == low | check ==high)) {
inrange = true;
}
else {
inrange = false;
}

}
return inrange;
}
// This overloaded method is like the int version above

public boolean checkExpect(int check, int expect){
if(check == expect)
return true;
else
return false;
}
// This method check to see if the values are the same

public boolean checkExpect(String check, String expect, boolean matchCase){

if(check.equals(expect))
return true;
else {
if(!matchCase && check.equalsIgnoreCase(expect))
return true;
else
return false;
}
}
// This method checks to see of the Strings are the same
// matchCase indicatates if we care about the case of letters or not
// if matchCase is false, vInNy is the same as vinny
// if matchCase is false, vInNy is not the same as vinny

public boolean yesNo(String prompt, Scanner input){
System.out.println(prompt);
if(input.hasNext()) {
String in = input.next();
if(in.equalsIgnoreCase("yes") || in.equalsIgnoreCase("y")){
return true;
}
else
return false;
}
else {
return false;
}
}
// This method asks a questions and checks if they responded with a yes or a y (any case)
}


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote