Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 3 Using a brute-force search, determine the minimum of a function f(x)x-

ID: 2261902 • Letter: P

Question

Problem 3 Using a brute-force search, determine the minimum of a function f(x)x-3x [-2, 21. What is the accuracy of this solution? Plot the function within that range. 2 +e in the range Problem 4 Write a function to convert Celsius degrees to Fahrenheit degrees and vice versa. The input should temperature T and the scale type (i.e. Celsius or Fahrenheit) while the scale type should be a string (either 'Celsius' or 'Fahrenheit'). e. Celsius or Fahrenheit) and the output should the the Temperatures should be real numbers, The conversion formulas to use are: (7,-32) and T,- Te +32

Explanation / Answer

problem 4

import java.io.*;

import java.util.*;

class GFG {

public static void main (String[] args) {

Scanner scan = new Scanner(System.in);

float temp = scan.nextInt();

String scale = scan.nextLine();

float out = 0;

String out_scale;

if(scale.equals("Fahrenheit"))

{

out = ((temp-32)*5)/9;

out_scale = "Celsius";

}

else

{

out = (9*temp+160)/5;

out_scale = "Fahrenheit";

}

System.out.println(out+" "+out_scale); }

}

working demo

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote