IN JAVA
write a class called mySchool that has no main method that provides the following (JUST HARD CODE NO MAIN)
min(int a, int b)
max(int a, int b)
avg(int a, int b)
sum(int a,int b)
convert(double a, string s) if s is F convert to celcius if s is C convert to faraenheit
Then write a seperate java program WITH a main to test all the methods from the class mySchool
class mySchool {
public static int min(int a, int b) {
if (a < b) {
return a;
} else {
return b;
}
}
public static int max(int a, int b) {
if (a > b) {
return a;
} else {
return b;
}
}
public static double avg(int a, int b) {
return (a + b) / 2.0;
}
public static int sum(int a, int b) {
return a + b;
}
public static double convert(double a, String s) {
if (s.equalsIgnoreCase("f")) {
return (a - 32) / 1.8;
} else {
return a * 1.8 + 32;
}
}
}
class testMySchool {
public static void main(String[] args) {
System.out.println(mySchool.max(2, 1));
System.out.println(mySchool.min(2, 1));
System.out.println(mySchool.avg(3, 9));
System.out.println(mySchool.sum(3, 9));
System.out.println(mySchool.convert(100, "f"));
System.out.println(mySchool.convert(38, "c"));
}
}
IN JAVA write a class called mySchool that has no main method that provides the following...
I need java code for the following problem.
Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that accepts one integer parameter and returns the value raised to the third power as an integer. o Write a method called randominRange that accepts two integer parameters representing a range. The method returns a random integer in the specified range inclusive. 2. o Write a method...
Write four overloaded methods called randomize. Each method will return a random number based on the parameters that it receives: randomize() - Returns a random int between min and max inclusive. Must have two int parameters. randomize() - Returns a random int between 0 and max inclusive. Must have one int parameter. randomize() - Returns a random double between min and max. Must have two double parameters. randomize() - Returns a random double between 0 and max. Must have one...
In Java: Main function must be in a separate class called "IncomeDemo" Write an "Income" class that stores the total monthly income for each of the 12 months into an array of doubles. The class should have methods that return the following: total income for the year average monthly income the month with the highest income the month with the lowest income Write a program that demonstrates this class. You'll need to pass a 12-element double array to the class...
Write a Java program that has a method called arrayAverage that
accepts an arrary of numbers as an argument and returns the average
of the numbers in that array. Create an array to test the code with
and call the method from main to print the average to the screen.
The array size will be from a user's input (use Scanner).
- array size = int
- avergage, temperature = double
- only method is arrayAverage
Output:
FIX THE FOLLOWING JAVA CODE
public class Errors public static main(String[] args) { float sum int a = 27.5, b = 72.99; suma(a, b); System.out.println("Suma = %7:3b", sum); } //end main public static suma(float a, double b) { double suma suma = a + b; } }//end class
AddressHelper Written in - JAVA Write a class called AddressHelper that provides the following static methods to help with formatting and printing addresses: addMrPrefix() Returns the string “Mr. “ concatenated with the String argument. addMsPrefix() Returns the string “Ms. “ concatenated with the String argument. determineStateAbbreviation() Takes a String argument containing a state. Returns the corresponding abbreviation as String using the following lookup table: New York NY New Jersey NJ California CS Florida FL other -- determineZipcode() Takes a String...
Java Code Help! Code this: Calculate statistics. Write a class called Statistics that can calculate a number of properties about an array of doubles. There should be separate static methods to calculate the min, the max, the mean, the median, the standard deviation (make sure to make use of your mean method to implement this), and the mode. For the mode, you can assume that the data set is not multimodal. This class should not have a main method. Write...
I need to create a code for this prompt: In this project we will build a generic UserInput class for getting keyboard input from the user. Implementation: The class UserInput is a 'Methods only' class, and all the methods should be declared static. Look at the TestScanner.java program at the bottom of this page that inputs a string, int and double. It shows you how to use Scanner class to get input from the keyboard. Write FOUR simple methods, one...
java question: Write a program that reads in data from a text file named in.txt. Compute the sum of all the valid integers in the input file. Likewise, compute the sum of all the valid doubles in the input file. Write the former to an output file called int_total.txt, and write the latter to an output file called double_total.txt. B) Write a program that converts the Java source code from the next-line brace style to the end-of-line brace style. For...
THE LANGUAGE IS JAVA!!
Define stubs for the methods called by the below main(). Each stub should print "FIXME: Finish methodName'followed by a newline, and should return -1. Example output: FIXME: Finish getUserNum() FIXME: Finish getUserNum() FIXME: Finish computeAvg() Avg: -1 import java.util.Scanner; 3 public class MthdStubsStatistics { 1* Your solution goes here */ public static void main(String [] args) { int userNum1; int userNum2; int avgResult; userNum1 = getUserNum(); userNum2 = getUserNum(); avgResult = computeAvg(userNumi, userNum2); System.out.println("Avg: " +...