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;
}
}
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.
|