0
votes

I made this program as a project for one of my classes, and upon compiling it, I get this error:

Program09.java:21: error: method calculateCelsius in class Program09 cannot be applied to given types; double cTemp = calculateCelsius(); ^ required: int found: no arguments reason: actual and formal argument lists differ in length Program09.java:24: error: method calculateCelsius in class Program09 cannot be applied to given types; calculateCelsius(); ^ required: int found: no arguments reason: actual and formal argument lists differ in length Program09.java:25: error: method displayResults in class Program09 cannot be applied to given types; displayResults(); ^ required: int,double found: no arguments reason: actual and formal argument lists differ in length 3 errors

This is the program below. Any help would be greatly appreciated!

import java.util.Scanner;

public class Program09
{
   public static void main(String[] args)
   {
       int fTemp = getFarenheit();
       double cTemp = calculateCelsius();
      displayInstructions();
      getFarenheit();
      calculateCelsius();
      displayResults();
   }
   public static void displayInstructions()
   {
       System.out.println("This program will convert farenheit to celsius");
       System.out.println("after you enter a farenheit temperature");
   }
   public static int getFarenheit()
   {
       System.out.println("Please enter your temperature below");
       Scanner keyboard = new  Scanner(System.in);
       return keyboard.nextInt();
   }
   public static double calculateCelsius(int farenheit)
   {
       return (5 * (farenheit - 32) / 9.0);
   }
   public static void displayResults(int fTemp, double cTemp)
   {
       System.out.println("Your farenheit temperature is " + fTemp);
       System.out.printf("Your celsius temperature is ", + cTemp);
       System.out.println("Thank you for using the program!");
       System.out.println("The rest of the world needs to conform to imperial measurments, cuz 'merica");
       return;

   }       
}
1
Welcome to Stack Overflow! Please do not vandalize your posts. By posting on the Stack Exchange network, you've granted a non-revocable right for SE to distribute that content (under the CC BY-SA 3.0 license). By SE policy, any vandalism will be reverted. - Paul Roub

1 Answers

0
votes

Your calling calculateCelsius without a parameter, you need to pass your parameter correctly, like this.

int fTemp = getFarenheit();
double cTemp = calculateCelsius(fTemp);

additionally displayResults will also fail for the same reason, pass in fTemp and cTemp when calling it