Skip to main content
0 online
theremin thereminOG 2002

What's wrong with this code?

import java.util.*;

public class Exercise14
{
static Scanner console = new Scanner(System.in);

public static void main(String [] args)
{
int first, third;
IntClass second, fourth;

first = 3;
second = new IntClass(4);
third = 6;
fourth = new IntClass(7);

System.out.println(first + " " + second.getNum()
+ " " + third + " "
+ fourth.getNum());
getData(first, second, third, fourth);
System.out.println(first + " " + second.getNum()
+ " " + third + " "
+ fourth.getNum());
fourth.setNum(first * second.getNum() + third +
fourth.getNum());
getData(third, fourth, first, second);
System.out.println(first + " " + second.getNum()
+ " " + third + " "
+ fourth.getNum());
}

public static void getData(int a, IntClass b, int c, IntClass d)

{
a = console.nextInt();
b.setNum(console.nextInt());
c = console.nextInt();
d.setNum(console.nextInt());

b.setNum(a * b.getNum() - c);
d.setNum(b.getNum() + d.getNum());
}

}

I'm getting this when I compile:

Exercise14.java:32: cannot find symbol
symbol : class IntClass
location: class Exercise14
public static void getData(int a, IntClass b, int c, IntClass d)
^
Exercise14.java:32: cannot find symbol
symbol : class IntClass
location: class Exercise14
public static void getData(int a, IntClass b, int c, IntClass d)
^
Exercise14.java:10: cannot find symbol
symbol : class IntClass
location: class Exercise14
IntClass second, fourth;
^
Exercise14.java:13: cannot find symbol
symbol : class IntClass
location: class Exercise14
second = new IntClass(4);
^
Exercise14.java:15: cannot find symbol
symbol : class IntClass
location: class Exercise14
fourth = new IntClass(7);
^
Exercise14.java:24: operator + cannot be applied to int,IntClass.getNum
fourth.setNum(first * second.getNum() + third +
^
6 errors

----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.

iwz iwz

First, have you created the IntClass? and is it in the same package as Exercise14?

Your compiler is not able to find IntClass. So, if you've already created it, then make sure you compile everything all together, like javac *

If you haven't created IntClass yet, here's what it should look like:

public class IntClass
{
private int num;

public IntClass( int num )
{
this.num = num;
}

public int getNum()
{
return num;
}

public void setNum( int num )
{
this.num = num;
}
}

theremin thereminOG 2002

I'm further humbled. Thanks. Big help.

Welcome Back to eZabel

It's been a while. Here's what's new.

eZabel Lore

A complete history of our community — stats, Hall of Fame, legendary threads, and more.

View the Lore →

Everything Preserved

All 225,969 pieces of content from 2000–2014 are here — forums, messages, journals, photos, polls, and events.

💎

Gems

Spot something you love — a legendary comment, a classic thread, a great photo? Log in and click the diamond icon to mark it as a Gem. Add a note about why it's special. The best stuff surfaces on the Gems page.