can you give multiple parameters?

0 shaun hester · February 18, 2015
not sure if thats the technical term but here is what i have
package buckysclass;
import java.util.Scanner;
class shaun{
  public static void main(String args[]){
    int girls, boys, people;
    girls = 11 ;
    boys =  3;
    people = girls / boys;
    group = girls % boys;
    System.out.println(people);
    System.out.println(group);
}
}




and the question is how would i have it print the number its divisible by then on the next line the remainder i keep getting an error with what i have . i know im over looking something.
this is the error im getting
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
    group cannot be resolved to a variable
    group cannot be resolved to a variable

    at buckysclass.shaun.main(shaun.java:9)
I guess what im asking is how do i get group resolved into the variable if i want to print out a second part

Post a Reply

Replies

Oldest  Newest  Rating
+2 Erik Schouten · February 18, 2015
You forgot to say that group is an int
+1 Jay Deshaun · February 19, 2015
No problem,
I'm guessing it worked
0 shaun hester · February 18, 2015
oh yeah ..ty amazing how you can stare at it and over look the little things ..again ty im going to change it now
0 shaun hester · February 18, 2015
still does not work for some reason ...I added group to my list of int..and even tried doing so on its own line it still will not ead as a variable. this is the error still..

.Exception in thread "main" java.lang.Error: Unresolved compilation problems:
    group cannot be resolved to a variable
    group cannot be resolved to a variable

    at buckysclass.shaun.main(shaun.java:9)


this is where I am at on the code right now i have it defined as an int
package buckysclass;
class patrick {
  public static void main(String args[]){
    int girls, boys, people;
    girls = 11 ;
    boys =  3;
    people = girls / boys;
    int group;
    group = girls % boys;
    System.out.println(people);
    System.out.println(group);
}
}


0 shaun hester · February 18, 2015
i see how group put it in to green text so i changed the word group into tuna still get the same error message
0 Jay Deshaun · February 19, 2015
Try switching the girls and boys:
group = boys % girls;

It works here either way:
http://goo.gl/ovOK0b
(Compile then Execute)^

EDITED:
Try this:
package buckysclass;
import java.util.Scanner;
class shaun{
    public static void main(String args[]){
        int girls=11, boys=3, people,tuna;
        people = girls / boys;
        tuna = girls % boys;
        System.out.println("Division: "+ people +", Remainder: "+ tuna );
    }
}
0 shaun hester · February 19, 2015
thank you
0 shaun hester · February 19, 2015
works great now
0 shaun hester · February 19, 2015
yes it did ..thank you im learning the if statements now
going to figure a way to use it outside of what happened in the video tutorial just to better emphasize how it works for me.
  • 1

Java / Android Development

107,024 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator