Error Method Cannot Be Applied To Given Types
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about
Method Main In Class Cannot Be Applied To Given Types
Stack Overflow the company Business Learn more about hiring developers or posting ads with java no main method found us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is error constructor cannot be applied to given types a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Java error: method in class cannot be applied to given types up vote 3
Constructor In Class Cannot Be Applied To Given Types Java
down vote favorite I am just trying to call the methods to the main for each switch when it happens, but i just get the error message everytime i try to call any methods, not trying to return anything. ex. if the user enters a or A i want to call the add method to main public static void main(String[] args) { char character; Scanner keyboard = new Scanner(System.in); while
Actual And Formal Argument Lists Differ In Length Java
(character != 'E' || character != 'e') { System.out.println(" A:Addition \n S:Subtraction \n M:Multiplication \n D:Division \n R:Modulus \n E:exit"); switch (character) { case 'a': case 'A': System.out.println("your choice A"); add(); break; case 's': case 'S': System.out.println("your choice S"); subtraction(); break; case 'm': case 'M': System.out.println("your choice M"); multiplication(); break; case 'd': case 'D': System.out.print("your choice D"); division(); break; case 'r': case 'R': System.out.println("your choice R"); modulus(); break; default: System.out.println("Error: please enter a valid letter"); break; } } } public static void add(Scanner keyboard) { int a,b; //get integer 1 System.out.println("enter integer 1"); a = keyboard.nextInt (); //get integer 2 System.out.println("enter integer 2"); b = keyboard.nextInt(); int total = a + b; System.out.println(a + "plus" + b + "is" + total ); } public static void subtraction(Scanner keyboard) { int a,b; //get integer 1 System.out.println("enter integer 1"); a = keyboard.nextInt (); //get integer 2 System.out.println("enter integer 2"); b = keyboard.nextInt(); int total = a-b; System.out.println(a + "minus" + b + "is " + total); } public static void multiplication(Scanner keyboard) { int a,b; //get integer 1 System.out.println("enter integer 1"); a = keyboard.nextInt (); //get integer 2 System.out.println("enter integer 2"); b = keyboard.nextInt(); int total = a*b; System.out.println(a + "times" + b + "is " + total); } public
here for a quick overview of the site Help actual and formal argument lists differ in length android Center Detailed answers to any questions you might have Meta
Constructor In Class Cannot Be Applied To Given Types Extends
Discuss the workings and policies of this site About Us Learn more about Stack missing return statement Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question http://stackoverflow.com/questions/28445862/java-error-method-in-class-cannot-be-applied-to-given-types x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Method cannot be applied to given types, trying to call my getMenuChoice() method up vote 0 http://stackoverflow.com/questions/19783436/method-cannot-be-applied-to-given-types-trying-to-call-my-getmenuchoice-metho down vote favorite I'm trying to call my getMenuChoice() method in my main method to output the things in my getMenuChoice() method but it is telling me that the method cannot be applied to the given types; required: String, String found: no arguments Why is this? Any help is appreciated, thanks. package footballgame; import java.util.Scanner; public class FootballGame { static Scanner keyboard = new Scanner(System.in); public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); String footballTeam1; String footballTeam2; System.out.print("Enter a name for a team:"); footballTeam1 = keyboard.nextLine(); System.out.print("Enter a name for another team:"); footballTeam2 = keyboard.nextLine(); System.out.println("Game Score:"); System.out.println(footballTeam1 + ":0"); System.out.println(footballTeam2 + ":0"); choice = getMenuChoice(); } public static String getMenuChoice(String footballTeam1,String footballTeam2){ String choice; do{ System.out.println("Select an option:"); System.out.println("A:" + footballTeam1 + "scored"); System.out.println("B:" + footballTeam2 + "scored"); System.out.println("C: game ended."); System.out.println("?:"); choice = keyboard.nextLine(); if (choice.equ
This Site Careers Other all forums Forum: Beginning Java Method in Class Cannot Be Applied to Given Types Michelle Purdy Greenhorn Posts: 10 posted 3 years ago We use BlueJ in our Java course https://coderanch.com/t/596555/java/java/Method-Class-Applied-Types and for this one assignment, I have two classes: Car and GasTank. The method drive() generates a random number of miles for one segment of a trip. Then I needed to write code to check to see if the gas tank is empty. If it is, do not allow movement of the car. If it isn't, call the burnGas() method of in the GasTank class. Then cannot be the printTripDetails() method is called to show the current status of the trip. Well, when I set up the If statement to check if the gas tank was empty, I get the following error message, which is Greek to me and I'm so confused. I have tried so many different things and nothing is working!! I'm really concerned that this is super simple stuff that I can't cannot be applied figure out and if I'm not understanding this then maybe I'm in the wrong field?? method burnGas in class GasTank cannot be applied to given types; required: double, double found: no arguments reason: actual and formal argument lists differ in length The operator that you use here cannot be used for the type of value that you are using it for. You are either using the wrong type here, or the wrong operator. Here is the code for Car, which probably has more errors than just what I've mentioned here: import java.util.Random; public class Car{ //the manufacturer of the car String make; //the model of the car String model; //the miles per gallon double mpg; double totalMilesDriven; //the GasTank GasTank tank; double tripDistance; /* * constructor for a default Car object */ public Car(){ //default GasTank tank = new GasTank(15); make = "Ford"; model = "Fusion"; totalMilesDriven = 0; mpg = 20; tripDistance = 500; this.beginTrip(); } /* * add a constructor for a Car with a specific gas tank size in gallons * * @param make the manufacturer of the Car * @param model the specific model of the Car * @param mpg number of miles