Hello, I have this code that's giving me some problems:

import java.util.Scanner;

class Bæreevne{
  public static void main(String[] args) {
  
    int avstand, vektTre, vektBetong;
    Scanner tastatur = new Scanner(System.in);
    
    System.out.print("Oppgi antall meter mellom søylene");
    avstand = tastatur.nextInt();
    
    vektTre = 3000 - 20*avstand*avstand;
    vektBetong = 7000 - 80*avstand*avstand;
    
    if (vektTre > vektBetong) {
      bæreevneTre(avstand, vektTre);
    }  else if (vektTre < vektBetong) {
      bæreevneBetong(avstand, vektBetong);
      }
  }
  
  public static int bæreevneTre(int avstand, int vektTre) {
    
    
    System.out.print("Med %d meter mellom søylene bør gulvet bygges i tre og kan bære %d kg.%n", avstand, vektTre);
      
    }
  
  public static int bæreevneBetong(int avstand, int vektBetong) {
    
    System.out.print("Med %d meter mellom søylene bør gulvet bygges i betong og kan bære %d kg.%n", avstand, vektBetong);
      
    }
}

It says error on line 25: cannot find symbol, but after hours of searching the web I can't figure out why. I just want it to go to the right method when called and then execute the printline in the method. Can anyone see what the problem is?
Thanks!

Line 25 you call print and pass three parameters. There is no print method in the PrintStream class that takes 3 parameters. You can concatenate those 3 params together into one String parameter, and that will print OK.

ps: your method also promises a return type of int, but returns nothing - that's wrong too.

3 parameters? You mean avstand and vektTre but what's the third? And how do I put them in a String variable? Sorry for being completely noob, but I'm tired and I've done this all day.

"M...n", avstand, vektTre

the two commas separate three parameters.

You can use the + operator to concatenate strings, and, even better, if you use it with a string and an int it will convert the int to a string automatically. So you can use something like
"Med %d meter mellom søylene bør gulvet bygges i tre og kan bære %d kg.%n" + avstand + " " + vektTre
to put all that together into a single String that you can print.
(I put an extra blank between the two ints so you can see where one ends and the other starts)

OR

Looking at the first string, although it means nothing to me, I'm suspicious about the % signs. Did you maybe mean printf, not print (in which case your 3 params would be perfectly OK)?

Thank you!! Yes, it was printf I i was gonna use, but as usually i forget that f. But now it worked :)

Great!. Mark this "solved" so no-one else worries about it.

The format looks really like C++ :P

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.