Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

package hw; import java.util.Arrays; public class Practice { static double average ( int a , int b , int c ) { / / Given

package hw;
import java.util.Arrays;
public class Practice {
static double average(int a, int b, int c){
// Given three values a, b, c, return the average value of those values.
return 0; // dummy to avoid syntax error. Change this as needed
}
static int min(int a, int b, int c){
// Given three values a, b, c, return the minimum value.
return 0; // dummy to avoid syntax error. Change this as needed
}
static double Celsius2Fahrenheit(int tempC){
// Given a temperature in Celsius, return the corresponding temperature in Fahrenheit
return 0; // dummy to avoid syntax error. Change this as needed
}
static double Fahrenheit2Celsius(double tempF){
// Given a temperature in Celsius, return the corresponding temperature in Fahrenheit
return 0; // dummy to avoid syntax error. Change this as needed
}
static int FeetInch2Cm(int[] height){
// Given a height as an int array [feet, inch], return the height in centimeter
// Round the height to the nearest integer value. eg)182.6 cm -->183 cm
return 0; // dummy to avoid syntax error. Change this as needed
}
static int[] Cm2FeetInch(int height){
// Given a height in centimeter, return the height as an int array [feet, inch]
// Round the height to the nearest integer values inches.
return null; // dummy to avoid syntax error. Change this as needed
}
static char charAfer(char ch, int n){
// Return the n-th character after the given character ch in ASCII order.
// eg) charAfer('a',1) returns 'b', charAfer('a',2) returns 'c', charAfer('1',3) returns '4'
return 0; // dummy to avoid syntax error. Change this as needed
}
static boolean isBetween(int[] interval, int val){
// Given an int array interval =[x1, x2],
// Return true if val is between x1 and x2(inclusively). Return false otherwise
// Assume x1<= x2
return false; // dummy to avoid syntax error. Change this as needed
}
static boolean overlap(int[] interval1, int[] interval2){
// Return true if the two intervals overlap. Return false otherwise.
// Return true if they have any value in common.
//[1,3] and [3,6] are overlapping
// Assume each interval has two values sorted. eg) interval[0]<= interval[1]
return false; // dummy to avoid syntax error. Change this as needed
}
static double areaTriangle(double a, double b, double c){
// Given three sides of a triangle, return its area.
// If any one side is equal or greater than the sum of the other two, it is invalid. Return -1.0 in such case
// eg) areaTriangle(1,2,3) returns -1.0
return 0; // dummy to avoid syntax error. Change this as needed
}
public static void main(String[] args){
System.out.println("testing average()");
System.out.println(average(1,2,3)); //2.0
System.out.println(average(1,2,10)); //4.333333333333333
System.out.println(average(-2,-5,1)); //-2.0
System.out.println("testing min()");
System.out.println(min(2,5,1)); //1
System.out.println(min(-2,5,1)); //-2
System.out.println(min(-2,-5,1)); //-5
System.out.println("testing Celsius2Fahrenheit()");
System.out.println(Celsius2Fahrenheit(0)); //32.0
System.out.println(Celsius2Fahrenheit(100)); //212.0
System.out.println(Celsius2Fahrenheit(-10)); //14.0
System.out.println("testing Fahrenheit2Celsius()");
System.out.println(Fahrenheit2Celsius(32)); //0.0
System.out.println(Fahrenheit2Celsius(-10)); //-23.333333333333332
System.out.println(Fahrenheit2Celsius(100)); //37.77777777777778
System.out.println(Fahrenheit2Celsius(Celsius2Fahrenheit(35))); //35.0
System.out.println("testing FeetInch2Cm()");
System.out.println(FeetInch2Cm(new int[]{6,2})); //188
System.out.println(FeetInch2Cm(new int[]{5,5})); //165
System.out.println(FeetInch2Cm(new int[]{7,4})); //224
System.out.println("testing Cm2FeetInch()");
System.out.println(Arrays.toString(Cm2FeetInch(188))); //[6,2]
System.out.println(Arrays.toString(Cm2FeetInch(165))); //[5,5]
System.out.println(Arrays.toString(Cm2FeetInch(225))); //[7,5]
System.out.println(FeetInch2Cm(Cm2FeetInch(170))); //170
System.out.println("testing charAfer()");
System.out.println(charAfer('a',1)); // b
System.out.println(charAfer('a',0)); // a
System.out.println(charAfer('a',10)); // k
System.out.println(charAfer('0',5)); //5
System.out.println(charAfer('B',40)); // j
System.out.println("testing isBetween()");
System.out.println(isBet

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

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions

Question

What are the diff erences between groups and teams?

Answered: 1 week ago

Question

If you were Dans friend, what might you say to alter his behaviors?

Answered: 1 week ago