• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Could someone help me out with this?

Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this involves changing the input data stream to include five days of information in order to generate the week's pay. The organization of the data file is workers first name, last name, hourly wage and then 5 sets of two numbers representing each day of the week. The first number in the pair represents regular hours for that day while the second number represents overtime hours for that day.
Kermit D.Frogge 5.25 0.0 8.0 1.5 8.0 2.25 7.75 0.0 8.0 2.0
Based on this organizational scheme, Kermit worked 5.25 regular hours on Monday and 0.0 overtime hours. On Tuesday, he worked 8.0 regular hours and 1.5 overtime hours, etc.....

* To change this template, choose Tools | Templates
* and open the template in the editor.

package project35;

* @author kirtida
* October 28, 2009
* Great Valley

* @param args the command line arguments

// file input demo

import java.io.*;
import java.util.StringTokenizer;

public class Project
// variables necessary for file input
private static FileInputStream inFile;
private static InputStreamReader inReader;
private static BufferedReader reader;

// StringTokenizer variable used to separate line into different data elements
private static StringTokenizer strTkn;

// program variables to hold data
private static String line,word;
private static int num1, num2,num3,grade, total;
private static double avg;

// throws IOException will have the operating system handle any problems
// that may occur while attempting to acquired data from the file.

public static void main (String args[]) throws IOException


// closing the data file
inFile = new FileInputStream ("//Users/106780/Desktop/HSAPCSData//test.txt");

// preparing the file for input

public static void initFile() throws IOException
inFile = new FileInputStream ("//Users/106780/Desktop/HSAPCSData//test.txt"); // notice the double slash marks
inReader = new InputStreamReader(inFile);
reader = new BufferedReader(inReader);

//data acquisition method

public static void getData() throws IOException
line = reader.readLine(); //acquiring the data line as a string
System.out.println ("data line = " + line ); // view data line as one string

strTkn = new StringTokenizer(line); // attaching the string tokenizer to the line

// placing the first word in the dataline into a string variable
word = strTkn.nextToken();

// extracting the parts of the line into separate int and double variables
grade = Integer.parseInt(strTkn.nextToken());
avg = Double.parseDouble(strTkn.nextToken());
num1 = Integer.parseInt(strTkn.nextToken());
num2 = Integer.parseInt(strTkn.nextToken());
num3 = Integer.parseInt(strTkn.nextToken());

// processing the int totals
public static void calcTotal()
total = num1 + num2 + num3;

// output results

public static void printResults()
System.out.println("Separated data line :");
System.out.println (grade);
System.out.println (avg);

System.out.println("sum of numbers = " + total);

} // end of class
Posts: 4179
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeff,

Can you edit your post and UseCodeTags which will make it easier to read. Also, TellTheDetails - what problem are you having?
Posts: 1840
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please also use a meaningful subject line....

It looks like that section came from another application. If you want to adapt it, that's fine, but you need to understand what you want and how to ask the computer to give it to you.

You should start in smaller sections.... get the file input to work and output to the screen, then divide it up into strings and output to screen. Then figure out what needs to be done from there.

My $0.02
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!