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

  Method named isallvowels that returns

Write a method named isAllVowels that returns whether a String consists entirely of vowels (a, e, i, o, or u, case-insensitively). If every character of the String is a vowel, your method should return true. If any character of the String is a non-vo..

  Create a deque class based on the discussion of deques

Create a Deque class based on the discussion of deques (double-ended queues) in this chapter. It should include insertLeft(), insertRight(), removeLeft(), removeRight(), isEmpty(), and isFull() methods.

  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.

  Write the bubble sort

The village of Marengo conducted a census and collected records that have household data, including the number of occupants in each household.

  Java application to display multiple choice questions

Write down the application which displays series of TEN(10) multiple choice questions: questions must cover all the Java. Each question must have four possible answers and only one answer must be correct.

  What position along the chord does minimum pressure occur

At what position along the chord does the minimum pressure occur? What is special about the point where C p is a maximum?

  Classes using set and get methods

Create a java program that contains two classes using set and get methods. I need the program to return the area and perimeter of a rectangle. I wrote a program and he returned to me saying I used the wrong constructors and didn't create a the sec..

  Create a java program to calculate the circumference

Create a Java program based on the geometric shapes. The program should begin by prompting you for the shape you want to calculate the circumference.

  Your letterinventory class must use an array

Your LetterInventory class must use an array of Counter objects. Note that there is no nextChar method in the Scanner class. You must use the next() method and then use a loop through the characters of the token that is returned. Ignore any character..

  Create a book class for the library application project

Create a Book class for the Library application project. In addition to properties of author and isbn, with setters/getters, the Book should override Object's base method "boolean equals(Object)" and have a "boolean validate()" method.

  Java program simulate a network

Java program simulate a network

  Java application prompt user to put in integer from keyboard

Write a java application that performs the following task: prompt user to put in an integer from the keyboard, search for the user input from the array created in step 1.

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