Advertisement

07.22.2008 at 05:29AM PDT, ID: 23584837
[x]
Attachment Details

I want to print something in the output file but it is not happening

Asked by Atouray in Sun Java System Web Server, Java Programming Language

Tags: Java, java 5.0

Well I am writing a Java program to calculate my daily and monthly wages and print the output to a file,
I can print the results in the console but i can print it in the output file. I tried figuring it out but i cant.

I have two main classes one for testing or calling the methods in the other class.

the name of the output file is wageout.txt

I even try to print
output.println("hello")
but nothing comes in the output

Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
import java.util.*;
import java.io.*;
import java.text.DecimalFormat;
public class myWageCalculator {
	 
	double sum =0;
	double wagetotal=0;
	public void tokenizing(){
		try{
		
	gettingData container[]= new gettingData[100];
	
		Scanner input = new Scanner(new FileInputStream("wage.csv"));
		PrintWriter output = new PrintWriter(new FileOutputStream("wageout.txt"));
		output.print("what the held is your problem");
		String line=input.nextLine();
		double hourin=0;
		double hourout=0;
		double tmininhr;
		double ftotal;
		
		DecimalFormat twoDecimal = new DecimalFormat ("0.00");
 
			
		int k=0;
		while(input.hasNextLine()){
			gettingData use = new gettingData();
			line = input.nextLine();
			StringTokenizer st = new StringTokenizer(line,",:");	   	    
		    use.setDate(st.nextToken());
		    use.setDay(st.nextToken());
		    use.setTimeinhr(st.nextToken());
		    use.setTimeinmin(st.nextToken());
		    use.setTimeouthr(st.nextToken());
		    use.setTimeoutmin(st.nextToken());
		 container[k++]=use;
		 
		 output.println("good");
			 
		}
		for(int i=0;i<container.length;i++){
			hourin=Double.parseDouble(container[i].getTimeinhr());
			hourout=Double.parseDouble(container[i].getTimeouthr());
			//hourin2=container[i+1].getTimeinhr();
			
			
			double totalhour = hourout-hourin;
			//System.out.println(totalhour);
			
			double timeinmin = Double.parseDouble(container[i].getTimeinmin());
			double timeoutmin=Double.parseDouble(container[i].getTimeoutmin());
			if(timeinmin==0.0){
				tmininhr = Double.parseDouble(container[i].getTimeoutmin())/60;
				ftotal=tmininhr+totalhour;
			}else if(timeinmin==timeoutmin){
				
				ftotal=totalhour;
			}else{
				tmininhr=(60-timeinmin+Double.parseDouble(container[i].getTimeoutmin()))/60;
				ftotal =tmininhr+totalhour-1;
			}
			
			sum = sum+ftotal;
			//total working hours for each day
			System.out.print(twoDecimal.format(ftotal));
			output.println("hello");
			output.print(twoDecimal.format(ftotal));
			//total wage for each day
			double wage = ftotal*29.7;
			System.out.println("			"+twoDecimal.format(wage));
			wagetotal=wagetotal+wage;
		 }
 
		output.close();
		input.close();
		//input.close();
	}catch(Exception e){
		
	}
	//total working hours the week
	System.out.println(sum);
	System.out.println(wagetotal);
	}
	
		
	}
 
 
class gettingData{
	private String Date;
	private String Day;
	private String Timeinhr;
	private String Timeouthr;
	private String Timeinmin;
	private String Timeoutmin;
	
	
	public void setDate(String date){
		Date=date;
	}
	
	public String getDate(){
		return Date;
	}
	
	public void setDay(String day){
		Day=day;
	}
	
	public String getDay(){
		return Day;
	}
	public void setTimeinhr(String timeinhr){
		Timeinhr=timeinhr;
	}
	public String getTimeinhr(){
		return Timeinhr;
	}
	
	public void setTimeinmin(String timeinmin){
		Timeinmin=timeinmin;
	}
	public String getTimeinmin(){
		return Timeinmin;
	}
	
	public void setTimeouthr(String timeouthr){
		Timeouthr=timeouthr;		
	}
	
	public String getTimeouthr(){
		return Timeouthr;
	}
	
	public void setTimeoutmin(String timeoutmin){
		Timeoutmin=timeoutmin;
	}
	public String getTimeoutmin(){
		return Timeoutmin;
	}
}
 
 
 
////////////////////////////////////////////////////////////
public class Tester {
	public static void main (String[]args){
		try{
		myWageCalculator caller = new myWageCalculator();
		caller.tokenizing();
		}catch(Exception e){
			
		}
	}
 
}
 
 
[+][-]07.22.2008 at 05:31AM PDT, ID: 22058583

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.22.2008 at 05:48AM PDT, ID: 22058730

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Sun Java System Web Server, Java Programming Language
Tags: Java, java 5.0
Sign Up Now!
Solution Provided By: aman123_123
Participating Experts: 4
Solution Grade: A
 
 
[+][-]07.22.2008 at 05:49AM PDT, ID: 22058738

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 05:51AM PDT, ID: 22058756

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 05:57AM PDT, ID: 22058799

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.22.2008 at 06:11AM PDT, ID: 22058930

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 06:15AM PDT, ID: 22058959

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 06:17AM PDT, ID: 22058981

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.22.2008 at 06:28AM PDT, ID: 22059085

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.22.2008 at 06:28AM PDT, ID: 22059090

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 06:59AM PDT, ID: 22059383

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 07:08AM PDT, ID: 22059495

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 07:17AM PDT, ID: 22059611

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 07:44AM PDT, ID: 22059956

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628