Write a method called hash midpoint

Assignment Help JAVA Programming
Reference no: EM13166928

Write a method called hasMidpoint that accepts three integers as parameters and returns 'true' if one of the integers is the midpoint between the other two integers; that is to is if one integer is exactly between the two others. The method should return false if no such midpoint relationship exists. For example, (7,4,10) should return false.


Below is what I've written down currently, although I haven't been able to get it to work yet. I've got the number inputs and am but can't get it to run my method at the end, which I think is correct. Any help would be appreciated. Thanks!

 

import java.util.*;

 

public class midPoint1{

public static void main(String[]args) {

int a, b, c;

Scanner console = new Scanner(System.in);

System.out.println("Enter a number: ");

a = console.nextInt();

System.out.println("Enter a second number: ");

b = console.nextInt();

System.out.println("Enter a third number: ");

c = console.nextInt();

hasMidpoint(a, b, c);

}

public static boolean hasMidpoint(int a, int b, int c) {

int midpoint = a + c;

if(b == midpoint) return true;

else

return false;

}

}

 

 

Reference no: EM13166928

Questions Cloud

One or more consecutive white spaces is a delimiter : Write a function which will determine how many words are in a given string. assume that one or more consecutive white spaces is a delimiter between words.
Pseudocode int an iterative one : Turn the following pseudocode int an iterative one, Assuming k is in T: if k is in T, Insert should change its associated item to x.
Design a circuit with 3 inputs : Design a circuit with 3 inputs (x,y,z) representing the bits in a binary number, and three outputs (a,b,c) also representing bits in a binary number. When the input is 1,2,3, the binary output should be one less than the inpu
Provide a recursive definition of sequence s : provide a recursive definition of sequence S of all Binary strings starting with 1. Include the base case, recursion and restriction.
Write a method called hash midpoint : Write a method called hasMidpoint that accepts three integers as parameters and returns 'true' if one of the integers is the midpoint between the other two integers; that is to is if one integer is exactly between the two others. The method should re..
Need a program that has the user enter a string : Need a program that has the user enter a string. The program will test to see if its a exact palindrome like "civic" or "level". then it should test if its an inexact palindrome like "a nut for a jar of tuna".
Sends data to best_songs.php on a server : Create a form that sends data to best_songs.php on a server. The form should have a text box for your name and a collection of at least four checkboxes representing kinds of songs (real or imaginary) and a radio button to indicate whether the selecte..
The plot thickens : Consider the following correspondence between letters/symbols and numbers: A=1, B=2, C=3, D=4, E=5, F=6, G=7, H=8, I=9, J=10, K=11, L=12, M=13, N=14, O=15, P=16, Q=17, R=18, S=19, T=20, U=21, V=22, W=23, X=24, Y=25, Z=26, a period is equal to 27, a c..
Describe the windows kernel : Describe the Windows kernel, including its two main components.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Data structures and algorithms

Code analysis and programming.

  Allow the user to display a work history report

The 'report screen' shall:Allow the user to display a work history report for an individual or for all employees for the two weeks prior to the report request.

  Elements from a html document

Function test Count List Elements should simply retrieve an array of all list elements on the page and assert that their total count is 3.

  Huge integer class

Huge Integer Class) Create a class HugeInteger which uses a 40-element array of digits to store integers as large as 40 digits each. Provide methods parse, toString, add and subtract. Method parse should receive a String, extract each digit using met..

  Generates a random number between 1 and 100

Write a program that generates a random number between 1 and 100 (inclusive) and then prompts the user to guess the number. The user should be given up to 10 chances to guess the number.

  Create a computer class

Create a computer class and assume computers have the following fields: String manufacture, double price, int year

  Wrappershallow and wrapperdeep

Each class is simply a wrapper class to hold a private array variable. int [] a; The default constructor for each class should initialize â??aâ??. Each class should have a toString() and equals(). Each class should have a setArray method that allows ..

  Uses a loop to populate a one-dimensional array

Write the following program that creates and uses a loop to populate a one-dimensional array that holds the even numbers between 1 and 12; creates and uses a loop to populate a second one-dimensional array that holds the odd numbers between 1 and 12;..

  To translate infix mathematical expression

Write a program in java to translate infix mathematical expression into postfix expression and a program to evaluate the postfix expression

  Graphics program that draws 12 strings

Write a graphics program that draws 12 strings, one each for the 12 standard colors, besides Color.WHITE, each in its own color. Provide a class ColorNameViewer and a class ColorNameComponent.

  Java enumeration lettergrade represent letter grades

Write a java enumeration LetterGrade that represents letter grades A through F, including plus and minus grades. Define a private instance variable holding a boolean value.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd