Java newb having variable trouble

I'm taking an intro to object oriented programming class. Our teacher barly speaks English and spends the entire class time lecturing about what object oriented means rather than going over syntax and programming tips. I am so sick of hearing about car factories =(
We are supposed to
"Write an applet that paints the pie chart associated with five categories whose percentages are given by variables percentage1 to percentage5 and corresponding labels are given by variables label1 to label5."
After spending 2 days on this, this is as far as I've gotten. I'm getting 19 errors and I just don't know what to do about any of them.
Any help would be most appreciated.
import javax.swing.JApplet;
import java.awt.*;
import java.util.Scanner;
import java.lang.Math;
public class Money extends JApplet
   public void paint (Graphics page)
int percentage1 = 10;
int percentage2 = 15;
int percentage3 = 20;
int percentage4 = 25;
int percentage5 = 30;
float workingstorage = 0;
int anglestartingpoint = 0;
String labe11 = "Rent and Utilities";
String label2 = "Transportation";
String labe13 = "Food";
String labe14 = "Educational";
String labe15 = "Miscellaneous";
workingstorage = percentage1 * 3.6;
percentage1 = Math.round(workingstorage);
page.setColor (Color.blue);
page.fillArc(10,10,300,300,anglestartingpoint,percentage1);
page.drawString(label1,320,10);
anglestartingpoint = percentage1;
workingstorage = percentage2 * 3.6;
percentage2 = Math.round(workingstorage);
page.setColor (Color.green);
page.fillArc(10,10,300,300,angelstartingpoint,percentage2);
page.drawString(label2,320,30);
angelstartingpoint = angelstartingpoint + percentage2;
workingstorage = percentage3 * 3.6;
percentage1 = Math.round(workingstorage);
page.setColor (Colpage.fillArc (10,10,300,300,angelstartingpoint,percentage3);
page.drawString(label3,320,50);
angelstartingpoint = angelstartingpoint + percentage3;
workingstorage = percentage4 * 3.6;
percentage1 = Math.round(workingstorage);
page.setColor (Color.yellow);
page.fillArc (10,10,300,300,angelstartingpoint,percentage4);
page.drawString(label4,320,70);
angelstartingpoint = angelstartingpoint + percentage4;
workingstorage = percentage5 * 3.6;
percentage1 = Math.round(workingstorage);
page.setColor (Color.cyan);
page.fillArc (10,10,300,300,angelstartingpoint,percentage5);
page.drawString(label5,320,90);
----jGRASP exec: javac -g censored
Money.java:33: possible loss of precision
found : long
required: int
          percentage1 = Math.round(workingstorage);
^
Money.java:36: cannot find symbol
symbol : variable label1
location: class Money
          page.drawString(label1,320,10);
^
Money.java:40: possible loss of precision
found : long
required: int
          percentage2 = Math.round(workingstorage);
^
Money.java:42: cannot find symbol
symbol : variable angelstartingpoint
location: class Money
          page.fillArc (10,10,300,300,angelstartingpoint,percentage2);
^
Money.java:44: cannot find symbol
symbol : variable angelstartingpoint
location: class Money
          angelstartingpoint = angelstartingpoint + percentage2;
^
Money.java:44: cannot find symbol
symbol : variable angelstartingpoint
location: class Money
          angelstartingpoint = angelstartingpoint + percentage2;
^
Money.java:47: possible loss of precision
found : long
required: int
          percentage1 = Math.round(workingstorage);
^
Money.java:49: cannot find symbol
symbol : variable angelstartingpoint
location: class Money
          page.fillArc (10,10,300,300,angelstartingpoint,percentage3);
^
Money.java:50: cannot find symbol
symbol : variable label3
location: class Money
page.drawString(label3,320,50);
^
Money.java:51: cannot find symbol
symbol : variable angelstartingpoint
location: class Money
angelstartingpoint = angelstartingpoint + percentage3;
^
Money.java:51: cannot find symbol
symbol : variable angelstartingpoint
location: class Money
angelstartingpoint = angelstartingpoint + percentage3;
^
Money.java:54: possible loss of precision
found : long
required: int
          percentage1 = Math.round(workingstorage);
^
Money.java:56: cannot find symbol
symbol : variable angelstartingpoint
location: class Money
          page.fillArc (10,10,300,300,angelstartingpoint,percentage4);
^
Money.java:57: cannot find symbol
symbol : variable label4
location: class Money
          page.drawString(label4,320,70);
^
Money.java:58: cannot find symbol
symbol : variable angelstartingpoint
location: class Money
          angelstartingpoint = angelstartingpoint + percentage4;
^
Money.java:58: cannot find symbol
symbol : variable angelstartingpoint
location: class Money
          angelstartingpoint = angelstartingpoint + percentage4;
^
Money.java:61: possible loss of precision
found : long
required: int
          percentage1 = Math.round(workingstorage);
^
Money.java:63: cannot find symbol
symbol : variable angelstartingpoint
location: class Money
          page.fillArc (10,10,300,300,angelstartingpoint,percentage5);
^
Money.java:64: cannot find symbol
symbol : variable label5
location: class Money
page.drawString(label5,320,90);
^
19 errors
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.

String labe11 = "Rent and Utilities"; // 'label' should end with an 'ell' not a 'one' char
String label2 = "Transportation";
String labe13 = "Food"; // 'label' should end with an 'ell' not a 'one' char
String labe14 = "Educational";
String labe15 = "Miscellaneous"; // 'label' should end with an 'ell' not a 'one' char
workingstorage = percentage1 * 3.6;
percentage1 = Math.round(workingstorage); // make that: '(int)Math.round(workingstorage)'
page.setColor (Color.blue);
page.fillArc(10,10,300,300,anglestartingpoint,percentage1);
page.drawString(label1,320,10);
anglestartingpoint = percentage1;
workingstorage = percentage2 * 3.6;
percentage2 = Math.round(workingstorage); // make that: '(int)Math.round(workingstorage)'
page.setColor (Color.green);
page.fillArc(10,10,300,300,angelstartingpoint,percentage2); // check the spelling of 'anglestartingpoint'etc. etc.
kind regards,
Jos

Similar Messages

  • Newbie having trouble with opt/rep regions

    Hi everyone. I'm migrating my site from simple, square html
    to nice, elegant css. I've done most of the work, but I'm having
    some trouble with templates. Here's an example of how a page
    created with a template will (hopefully) look:
    http://www.technfun.com/temp/example.html
    I've succeeded in making the article region (inside the white
    frame) editable, but I can't figure out how to handle the side bar
    menu. It's supposed to contain links to the chapters and
    subchapters of the main article, so that clicking there will bring
    you to the right place in the page (a simple # link, in other
    words). However, the article writer (me) needs to be able to add as
    many "SidebarLarge" entries as necessary. Under each of those there
    may or may not be the need to add "SidebarSmall" entries for
    subchapters.
    I read the help file and figured out I need to do something
    with the optional and repeating region settings, but whenever I try
    I only ever manage to make a mess of the sidebar. Anyone can tell
    me how exactly I'm supposed to do this?
    Thanks :)

    Why not just make the whole sidebar an editable region
    instead? Then you
    can add as much stuff as you see fit.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "TechNFun" <[email protected]> wrote in
    message
    news:gda2tq$2v9$[email protected]..
    > Hi everyone. I'm migrating my site from simple, square
    html to nice,
    > elegant
    > css. I've done most of the work, but I'm having some
    trouble with
    > templates.
    >
    [url=http://www.technfun.com/temp/example.html]Here[/url]'s an
    example of
    > how a
    > page created with a template will (hopefully) look.
    >
    > I've succeeded in making the article region (inside the
    white frame)
    > editable,
    > but I can't figure out how to handle the side bar menu.
    It's supposed to
    > contain links to the chapters and subchapters of the
    main article, so that
    > clicking there will bring you to the right place in the
    page (a simple #
    > link,
    > in other words). However, the article writer (me) needs
    to be able to add
    > as
    > many "SidebarLarge" entries as necessary. Under each of
    those there may or
    > may
    > not be the need to add "SidebarSmall" entries for
    subchapters.
    >
    > I read the help file and figured out I need to do
    something with the
    > optional
    > and repeating region settings, but whenever I try I only
    ever manage to
    > make a
    > mess of the sidebar. Anyone can tell me how exactly I'm
    supposed to do
    > this?
    > Thanks :)
    >

  • Urgent : java bean having bidirectional one to many relationship

    Hi,
    We have complex requirement in our application.
    We need to copy java bean having bidirectional one to many relationship to another javabean having bidirectional one to many relationship..
    E.g
    Class Basket1 {
    public String color;
    pubic String type;
    public List<Basket1> basketList = new ArrayList()
    Class Basket2 {
    public String color;
    pubic String type;
    public List<Basket2> basketList = new ArrayList()
    We need to exact copy Basket1 to Basket2. We are in trouble to copy List of child because we do not have how many child Basket1 have of same type..
    Can someone help us how we can implement such kind of complex object bidirectional one to many relationship??

    I can't see anything bidirectional about these relationships. What I can see is a couple of BasketN classes that look identical so I don't know why they both exist, and they both contain lists of themselves as members, which suggests some kind of tree structure. Nothing bidirectional there. I can see tat these things can form circular object graphs but I don't see why you would want to do that.
    We need to exact copy Basket1 to Basket2And I don't know what that means. Please explain.

  • I'm having big trouble with my new mainboard: Part II

    Hi  
    I haven't got any more replies to my post "I'm having big trouble with my new mainboard" by Krelian 2003.09.13 at 05:25. Please help! I've been struggling with this for a LONG time. And now my computer won't boot at all! Sometimes the LED's in front of the computer lights up for half a second, and nothing more happens. The only sign of life is the green light in the LAN jack. It happened after I took the ide cable for my harddrive in and out of the mainboard. This is insane, how can that suddeny happen :O ?! I was asked by wonkanoby to post max amps for my PSU, I did, and I really need to know if I maybe need a new PSU, since he asked that. Can a new PSU solve all the problems mentioned in my previous posts? Everything was fine except that I couldn't get into Windows, before i tried another harddrive on my computer. How can that complicate things so much? I have tried going barebone, and taking out the cmos battery and setting the jumpers JBAT1, J10 and J11. I have also tried every suggestion I got. Please help! I really need to get this fixed!
    -Krelian

    Some power supplies or designed so that if there is a short or overload they shut them selfs off and some will not turn back on. Some have a relay that will click back on and work, some you have to  cycle the power switch. Those that won't come back on will have to be replaced. I'm not saying that yours is that type as I have no way of telling. But if you have a friend who will loan you a good power supply you might try it. As someone else said just turning off the power will not darn all the power from some motherboards. To test this turn off your power supply than turn on the computer with the start botton. Mine will flash the lights and fans will start to spin than die. So every time you turn off computer to work on it. After turning off PSU hit the start botton to drian any power left in it before working on it. Also do this after unplugging it just to make sure.

  • HT201342 I am having some trouble trying to back up my notes to my iCloud account, i have tried to delete my icloud account and create a new one, but still when i back my phone up on iCloud my notes do not seem to be backed up.How can i back up by notes o

    I am having some trouble trying to back up my notes to my iCloud

    Not photos, just data synced with iCloud shown in Settings>iCloud.  If you don't have sufficient storage to back up to iCloud, back up to your computer instead using iTunes (connect you phone to your computer, open iTunes, click on the name of your phone in iTunes, go to ths Summary tab of your iTunes sync settings and click Back Up Now).  Also transfer your purchases to your iTunes library (connect your phone to your computer, open iTunes and go to File>Devices>Transfer Purchases). If you have photo stream photos older than 30 days tha you wan to save, save these to your camera roll before backing up (tap Select, tap the photos, tap the share icon -- box with upward facing arrow, then tap Save to Camera Roll).
    When setting up your new phone, when given the option choose Restore from iTunes Backup and restore the backup you made earlier.

  • I'm having some trouble transferring audio books to my iPhone.  It usually takes 3 or 4 tries to get all the parts transferred.  I didn't use to have this problem - all parts would transfer in one try.

    I'm having some trouble transferring audio books to my iPhone.  It usually takes 3 or 4 tries to get all the parts transferred.  I didn't use to have this problem - all parts would transfer in one try.

    carolinechx wrote:
    i know the description may be a little bit too confusing
    Mostly because you are not using any capital letters or paragraph returns and your post is difficult to read.

  • Hello everyone! I'm having a trouble... I need to download Adobe Illustrator for windows 8, but i'm not able for doing that. Can you help me Please?

    Hello everyone! I'm having a trouble... I need to download Adobe Illustrator for windows 8, but i'm not able for doing that. Can you help me Please?

    Downloadable installation files available:
    Suites and Programs:  CC 2014 | CC | CS6 | CS5.5 | CS5 | CS4, CS4 Web Standard | CS3
    Acrobat:  XI, X | 9,8 | 9 standard
    Premiere Elements:  13 | 12 | 11, 10 | 9, 8, 7 win | 8 mac | 7 mac
    Photoshop Elements:  13 |12 | 11, 10 | 9,8,7 win | 8 mac | 7 mac
    Lightroom:  5.7.1| 5 | 4 | 3
    Captivate:  8 | 7 | 6 | 5.5, 5 | 1
    Contribute:  CS5 | CS4, CS3 | 3,2
    FrameMaker:  12, 11, 10, 9, 8, 7.2
    Download and installation help for Adobe links
    Download and installation help for Prodesigntools links are listed on most linked pages.  They are critical; especially steps 1, 2 and 3.  If you click a link that does not have those steps listed, open a second window using the Lightroom 3 link to see those 'Important Instructions'.

  • HI I'm having real trouble opening my word documents (using Office:Mac 2008)  Have tried repair disk options as I saw this advice on another blog, seemed to work for a while now its stared happening again.  Any help MUCH appreciated

    HI I'm having real trouble opening my word documents (using Office:Mac 2008)  Have tried repair disk options as I saw this advice on another blog, seemed to work for a while now its stared happening again.  Any help MUCH appreciated

    http://answers.microsoft.com/en-us/mac

  • How to store multiline string literal in to java bean shell variable

    Hello Experts
    How to store multiline string literals in java bean shell like we use triple quote for jython variable
    Using Jython
    str=""" helllo
    welcome to my world"""
    above syntax is working but not for java bean shell like below
    String str=""" hello
    welcome to my world""";
    So how to do this in java bean shell. I came to this scenario while storing logs to a variable. I believe there is no solution for storing multiline strings to java bean shell variable.
    <@
    String str="<%=odiRef.getPrevStepLog("MESSAGE")%>";
    @>
    Any suggestion will be highly appreciated.
    Thank You.

    maddythehunk wrote:
    Im trying this but its not working...
    while(billingQueryParamsItr.hasNext()) {
         billingQueryParam = (BillingQueryParam) billingQueryParamsItr.next();
         System.out.println("****** Param Name-->"+billingQueryParam.getParamName());
         String[0] name = billingQueryParam.getParamName(); // giving error ; expected
         //billingItemActionForm.setParamName(billingQueryParam.getParamName());
    Declare the array outside of the loop. Fill the array as you iterate. And stop putting your error messages inside of comments in the code.

  • Binding a JavaFX variable to a Java class instance variable

    Hi,
    I am pretty new to JavaFX but have been developing in Java for many years. I am trying to develop a JavaFX webservice client. What I am doing is creating a basic scene that displays the data values that I am polling with a Java class that extends Thread. The Java class is reading temperature and voltage from a remote server and storing the response in an instance variable. I would like to bind a JavaFx variable to the Java class instance variable so that I can display the values whenever they change.
    var conn: WebserviceConnection; // Java class that extends Thread
    var response: WebserviceResponse;
    try {
    conn = new WebserviceConnection("some_url");
    conn.start();
    Thread.sleep(10000);
    } catch (e:Exception) {
    e.printStackTrace();
    def bindTemp = bind conn.getResponse().getTemperature();
    def bindVolt = bind conn.getResponse().getVoltage();
    The WebserviceConnection class is opening a socket connection and reading some data in a separate thread. A regular socket connection is used because the server is not using HTTP.
    When I run the application, the bindTemp and bindVolt are not updated whenever new data values are received.
    Am I missing something with how bind works? Can I do what I want to do with 'bind'. I basically want to run a separate thread to retrieve data and want my UI to be updated when the data changes.
    Is there a better way to do this than the way I am trying to do it?
    Thanks for any help in advance.
    -Richard

    Hi,
    If you don't want to constantly poll for value change, you can use the observer design pattern, but you need to modify the classes that serve the values to javafx.
    Heres a simple example:
    The Thread which updates a value in every second:
    // TimeServer.java
    public class TimeServer extends Thread {
        private boolean interrupted = false;
        public ValueObject valueObject = new ValueObject();
        @Override
        public void run() {
            while (!interrupted) {
                try {
                    valueObject.setValue(Long.toString(System.currentTimeMillis()));
                    sleep(1000);
                } catch (InterruptedException ex) {
                    interrupted = true;
    }The ValueObject class which contains the values we want to bind in javafx:
    // ValueObject.java
    import java.util.Observable;
    public class ValueObject extends Observable {
        private String value;
        public String getValue() {
            return this.value;
        public void setValue(String value) {
            this.value = value;
            fireNotify();
        private void fireNotify() {
            setChanged();
            notifyObservers();
    }We also need an adapter class in JFX so we can use bind:
    // ValueObjectAdapter.fx
    import java.util.Observer;
    import java.util.Observable;
    public class ValueObjectAdapter extends Observer {
        public-read var value : String;
        public var valueObject : ValueObject
            on replace { valueObject.addObserver(this)}
        override function update(observable: Observable, arg: Object) {
             // We need to run every code in the JFX EDT
             // do not change if the update method can be called outside the Event Dispatch Thread!
             FX.deferAction(
                 function(): Void {
                    value = valueObject.getValue();
    }And finally the main JFX code which displays the canging value:
    // Main.fx
    import javafx.stage.Stage;
    import javafx.scene.Scene;
    import javafx.scene.text.Text;
    import javafx.scene.text.Font;
    import threadbindfx.TimeServer;
    var timeServer : TimeServer;
    var valueObjectAdapter : ValueObjectAdapter = new ValueObjectAdapter();
    timeServer = new TimeServer();
    valueObjectAdapter.valueObject = timeServer.valueObject;
    timeServer.start();
    Stage {
        title: "Time Application"
        width: 250
        height: 80
        scene: Scene {
            content: Text {
                font : Font {
                    size : 24
                x : 10, y : 30
                content: bind valueObjectAdapter.value;
    }This approach uses less cpu time than constant polling, and changes aren't dependent on the polling interval.
    However this cannot be applied to code which you cannot change obviously.
    I hope this helps.

  • I'm having a trouble getting icloud mail without my personal email. All icloud features syncs unless mail didn't sync I am running mac ox 10.7.2 any ideas?

    I’m having a trouble getting icloud mail without my personal email. All icloud features syncs normally unless mail didn’t sync I am running mac ox 10.7.2 any ideas?

    I discovered that my cord was bad. I used someone else's cord and then it worked - that's how I was able to determine it was the cord, so I replaced it. (In case someone else has a similar problem.)
    BTW, I'm still having a problem syncing my iCal, so I posted that problem in the iCal forum. If you think you can help, please look for my message there.

  • TS3276 I have installed OS X Mavericks on macbook pro, macbook air & iMac but I am having terrible trouble with apple Mail. I need to take all accounts online frequently OR worse I have to quit mail and restart computer. Is anyone else having problems?

    I have installed OS X Mavericks on macbook pro, macbook air & iMac but I am having terrible trouble with apple Mail. I need to take all accounts online frequently OR worse I have to quit mail and restart computer. Is anyone else having problems?

    I just checked to see if the update to OS X Yosemite 10.10.1 solved any of the issues outlined in my previous post, and to my dismay, nothing has changed -- all of the previous problems persist.
    My iMac (8) -- it's renamed itself eight times since the recent troubleshoot with the Apple tech rep -- shows up as a shared device in Finder on my MacBook Pro, but when I click on it, I cannot establish a connection using "Connect As".  So I've attempted to connect using the menu "Go/Connect to Server...", using both (alternately) the iMac's name and IP address, to no avail.  I get a message which reads: "There was a problem connecting to the server 'Peter's iMac (8)'. This server may not exist or it is unavailable at this time.  Check the server name or IP address, check your network connection, and then try again."
    Here's what I know:
    The server -- Peter's iMac (8) does exist;
    The server -- Peter's iMac (8) is available at this time;
    The server name -- Peter's iMac (8) -- is correct, as specified in the system sharing preferences;
    The server IP address is correct, as specified in the system sharing preferences;
    The network connection is active when I attempt to connect.
    I'm convinced the problems stem directly from the OS X Yosemite update.  None of this was ever remotely an issue in the previous OS X's -- any of them.  This is maddening!  What can be done?  Apple?? Anyone???

  • Java newbie help (type casting, 64bit unsigned Long)

    Hi I am java newbie and need help on my project. I have a few questions. Can you put strings in a hashtable and test for their being their with the appropriate hashtable method? I want to test for equal strings, not the same object. Second question can you use all 64 bits of an unsigned long? java doesn't seem to allow this. Any packages that do?
    Thanks,
    Dave

    Try casting it to Long instead of long. Long (capital L) is an Object, while long (lower case l) is not. You may also check to make sure the value isn't null. I would have thought that autoboxing would have worked here unless the value was null. But I am no expert on autoboxing.
    Edit >> Checking for null ain't a bad idea but has nothing to do with the problem - this is a compile time problem. Sorry.
    Also>> This code should work:
    long cTime=(Long)session.getAttribute("creationtime");Edited by: stevejluke on Jul 1, 2008 11:00 AM

  • I am having download trouble...

    Exit Code: 6
    Please see specific errors below for troubleshooting. For example, ERROR:
    -------------------------------------- Summary --------------------------------------
    - 0 fatal error(s), 2 error(s)
    ----------- Payload: Microsoft Visual C++ 2012 Redistributable Package (x86) 11.0.61030.0 {873BE68F-480F-49A6-9649-F98CAB056AFC} -----------
    ERROR: Third party payload installer vcredist_x86.exe failed with exit code: -2147024546
    ERROR: Failed to install Microsoft Visual C++ 2012 Redistributable Package (x86). Please try installing it by double clicking on the executable at "C:\Users\Admin\AppData\Local\Temp\{7C4DC876-83A1-49B9-8662-C737F8A5B9AB}\Illustrator_18_ LS20_win64\Adobe Illustrator CC 2014\payloads\Microsoft VC 2012 Redist (x86)\vcredist_x86.exe", or download and install the latest Microsoft Visual C++ 2012 Redistributable Package (x86) from Microsoft website - www.microsoft.com
    i am having download trouble...

    **** roko10044517 did you reinstall the Microsoft Visual C++ Redistrubitable per the error message you posted?
    "download and install the latest Microsoft Visual C++ 2012 Redistributable Package (x86) from Microsoft website - www.microsoft.com"

  • How to call java method having array as argument from c++ ?

    Hello sir,
    how to call java method having array as arguments from c++;
    here is java code which is called from c++
    class PQR {
         public void xyz(int[] ia) {
         System.out.println("hi");
              for (int i = 0; i < ia.length; i++)
                   System.out.println(ia);
    suppose all jvm invocation is done...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    For someone well versed in java, C++ and JNI although tedious that should be obvious.
    For someone not well versed in all three it is going to be very difficult.
    Even for someone that does have knowledge in all of those areas coming up with a C++ interface that reflects that functionality in a dynamic way such that anyone is will to use it is going to be quite an adventure.
    At any rate to start building it you do exactly the same thing that you would in java.
    1. Extract everything in the jar via the zip package
    2. For each found instance extract all of the methods, return types, parameters, etc and build a description tree for each class.
    Doing all of that in C++ is going to take a LOT of code. If someone wanted an estimate from me it would take me 6 months to do it. And before I would even attempt it I would get them to explain to me in detail exactly how they thought they were going to use it when I was done because I can't see any reasonable way to do that.
    I left out the description tree itself. I suppose you could duplicate the entire reflection api in C++.
    Now perhaps if it was much, much more constrained, like to only those classes that implement a single interface then that would be more reasonable.

Maybe you are looking for