Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Accessing toolkit

  1. #1
    Junior Member
    Join Date
    Apr 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Accessing toolkit

    Hi I'm trying to access the toolkit for an assignment I'm writing and I keep getting the same compiler message. What am I doing wrong?

    import java.text.DecimalFormat;
    import java.io.*;
    import java.util.Scanner;

    public class Robert_Gardner_6_07
    {
    public static void main(String[] args) throws IOException
    {
    // Delcare them variables
    // File names
    final String INPUT_FILE_NAME = "RobertGardner_6_07_Input.txt";
    final String OUTPUT_FILE_NAME = "RobertGardner_6_07__Output.txt";

    // Append current file boolean variable
    final boolean APPEND_INDICATOR = false; // Create a new file

    int numberOfNumbers = 0; // Number of numbers in input file
    double reImb = 0; // Used for reimbursement amount
    double oneNumber; // A single number read from the file
    double sum = 0; // Sum of milage calculated
    double sumReimb = 0; // Sum of reimbursement
    String processPhrase; // Indicates appending or creating a file

    // Access the Toolkit using the variable 'tools'
    Toolkit_General tools = new Toolkit_General();

    // Access the input and output files
    File inputDataFile = new File(INPUT_FILE_NAME); // Access input
    Scanner inputScanner = new Scanner(inputDataFile);
    FileWriter outputDataFile = new FileWriter(OUTPUT_FILE_NAME ,APPEND_INDICATOR);
    PrintWriter outputFile = new PrintWriter(outputDataFile);

    // Format numeric output
    DecimalFormat formatter = new DecimalFormat("#,##0.0");

    if (APPEND_INDICATOR)
    processPhrase = "Appending";
    else
    processPhrase = "Creating";
    // Display file information on console
    System.out.println("Reading file " + INPUT_FILE_NAME + "\n" +
    processPhrase + " file " + OUTPUT_FILE_NAME);

    // Display heading in output file
    if (inputScanner.hasNext()) {
    printHeading();
    outputFile.println("Miles and Reimbursement");
    outputFile.println("-----------------------");
    }

    // Read the input file and sum the numbers.
    while (inputScanner.hasNext())
    {
    inputScanner.nextLine();
    oneNumber = inputScanner.nextDouble();
    numberOfNumbers++;
    sum += oneNumber;

    // Print number to output file
    outputFile.println(oneNumber);

    if (oneNumber < 400) {
    reImb = (oneNumber * .018);
    sumReimb += reImb; // Add reimbursement amount to total
    } else if (oneNumber >= 400 && oneNumber < 900) {
    reImb = 65.00 + (0.15 * (oneNumber - 400));
    sumReimb += reImb; // Add reimbursement amount to total
    } else if (oneNumber >= 900 && oneNumber < 1300) {
    reImb = 115.00 + (0.12 * (oneNumber - 800));
    sumReimb += reImb; // Add reimbursement amount to total
    } else if (oneNumber >= 1300 && oneNumber < 1900) {
    reImb = 140.00 + (0.10 * (oneNumber - 1200));
    sumReimb += reImb; // Add reimbursement amount to total
    } else if (oneNumber >= 1900 && oneNumber < 2600) {
    reImb = 165.00 + (0.08 * (oneNumber - 1800));
    sumReimb += reImb; // Add reimbursement amount to total
    } else if (oneNumber >= 2600) {
    reImb = 195.00 + (0.06 * (oneNumber - 2500));
    sumReimb += reImb; // Add reimbursement amount to total
    } // End if

    if (oneNumber <= 0) {
    outputFile.println("" + tools.padItString("*****",10," "," "));
    } else {
    outputFile.println(" " + tools.leftPad(reImb,10,"#,##0.00"," "));
    } // End second if checking milage <= 0
    } // End while


    // Print the calculations to the output file
    String summary = "\nNumber of values: " + tools.leftPad((numberOfNumbers),
    10,"#,##0.00"," ") + "\nMiles Calculated: " +
    tools.leftPad(sum,10,"#,##0.00"," ") + "\nReimbursement: "
    + tools.leftPad(sumReimb,13,"#,##0.00"," ") + "\nValues >= Zero: "
    + tools.leftPad((9),12,"#,##0.00"," ") ;
    outputFile.println(summary);

    // Close files
    outputFile.close();
    inputScanner.close();


    } // End Main
    // Method to print heading
    public static void printHeading()
    {
    System.out.println("Mileage Reimbursement Table");
    }

    } // End Class



    compiler keeps saying:
    ----jGRASP exec: javac -g Robert_Gardner_6_07.java
    Robert_Gardner_6_07.java:37: cannot find symbol
    symbol : class Toolkit_General
    location: class Robert_Gardner_6_07
    Toolkit_General tools = new Toolkit_General();
    ^
    Robert_Gardner_6_07.java:37: cannot find symbol
    symbol : class Toolkit_General
    location: class Robert_Gardner_6_07
    Toolkit_General tools = new Toolkit_General();
    ^
    2 errors


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,166
    My Mood
    Hungover
    Thanks
    141
    Thanked 597 Times in 512 Posts

    Default Re: Accessing toolkit

    When posting code, please use the highlight tags and post an MCVE instead of your whole program.

    What is the Toolkit_General class? It's not in the standard Java API, so it must be a class you or your teacher created. Is it on your classpath?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Java Shared Data Toolkit
    By cjchanni in forum What's Wrong With My Code?
    Replies: 0
    Last Post: January 21st, 2013, 08:09 AM
  2. Seeking host for Google Web Toolkit
    By laresistance2 in forum Web Frameworks
    Replies: 1
    Last Post: June 9th, 2011, 04:29 AM
  3. Replies: 3
    Last Post: March 3rd, 2011, 01:17 PM
  4. accessing
    By gcsekhar in forum Java Native Interface
    Replies: 1
    Last Post: December 14th, 2010, 09:04 PM
  5. Toolkit.getSystemSelection problem
    By Paul.Baker in forum AWT / Java Swing
    Replies: 0
    Last Post: October 19th, 2010, 12:28 PM

Tags for this Thread