Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Must be in JAVA thank you for your help. Write a class RangeInput that allows users to enter a value within a range of values

Must be in JAVA thank you for your help.

Write a class RangeInput that allows users to enter a value within a range of values that is provided in the constructor. An example would be a temperature control switch in a car that allows inputs between 60 and 80 degrees Fahrenheit. The input control has up and down buttons. Provide up and down methods to change the current value. The initial value is the midpoint between the limits. As with the preceding exercises, use Math.min and Math.max to limit the value. Write a sample program that simulates clicks on controls for the passenger and driver seats.

RangeInput.java-can be edited

Public class RangeInput{

private int currentValue;

private int highValue;

private int lowValue;

public Range Input (int low, int high){

//this is the constructor

// your code here

}

public void up(){

//this is a mutator method

// that increases currentValue if allowed

// your code here

}

public void down(){

//this is a mutator method

//that decreases currentValue if allowed

// your code here

}

public int getCurrentValue(){

// this is an accessor method

//your code here

}

}

RangeInputTester.java- Dont change CODE

Public class RangeInputtester{

public static void main(String[] args){

rangeInput myInput = new RangeInput (40,50);

System.out.println(current value: + myInput.getCurrentValue());

for (int i = 0; i < 4; i ++){

myInput.up();

}

System.out.println(last value: +myInput.getCurrentValue());

}

}

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

Step: 3

blur-text-image

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

Successful Keyword Searching Initiating Research On Popular Topics Using Electronic Databases

Authors: Randall MacDonald, Susan MacDonald

1st Edition

0313306761, 978-0313306761

More Books

Students also viewed these Databases questions