O Mainjava>- import java. io.File; 1 2 import java.io.FilelotFoundException; import java. io.Filewriter; iport java.io.IOException; 3\ 4. import java.util.Arraylist; import java.util.Scanner; public class Main 10 static public double calcTax (double salary, double taxRate) 11 12 double taxOwed= 0; taxOwed = (salary taxRate) / 180; return taxOwed; 13 14 15 16 Run | Debug public static void main(Strinc[] args) throws I0Exception 17 18 19 Arraylist salary - new Arraylist(); 20 ArrayList name - new Arraylist(); Arraylist company_name - new Arraylist(); // int lines 1; 21 22 23 24 try{ File myFile - new File(pathname: "taxpayer.txt"); Scanner fileReader- new Scanner (myFile); 25 26 Ln 5, Col 28 Spaces 4 UTF O Mainjava X E taspayer bt Fuenfbt O Mainjava 24 try{ File myFile - new File(pathnane: "taxpayer.txt"); Scanner fileReader - new Scanner (myFile); 25 26 27 while(fileReader.hasNextline()){ 28 String data - fileReader.nextLine(); 29 System.out.printin(data); String[] datahrr - data. split(regex: ", "); name. add(dataArr[0] + " "+ dataArr[1] ); company_name.add (dataarr(2]); double sal - Double.parseDouble(dataarr[3]); salary.add(sal); // if(lines X 3 -- 1 ){ 30 31 32 33 34 35 36 // name.add(data); // Jelse if(1ines X 3 2)0 // // }else( // 37 38 company_name. add(data); 39 40 double sal - Double.parseDouble(data); 41 // salary.add (sal); 42 43 // lines; 44 45 filekeader.close(); 46 }catch (FileNotFoundException e){ 47 System.out.println(x: "File with given name not found"); e.printStackTrace(); 48 49 50 Ln 5, Col 28 Spaces 4 UTF O Mainjava X F taxpayer.bt Ftaint bt O Mainjava>. 48 e.printStackTrace(); 49 50 try(Fileiriter myiriter- new Filewriter(fileName: "taxinf.txt", append: true)) 51 52 System.out.println(x: "Records started in file .."); for (int i-0; i

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%
Please help how do I put all information in line during the output both the code and my example are presented below in the photos
O Mainjaa>
import java.io.File;
import java.io.FileNotFoundException;
import java.io.Filewriter;
iport java.io.IOException;
1
2
3\
4.
import java.util.ArrayList;
import java.util.Scanner;
7
public class Main
{
10
static public double caleTax (double salary, double taxRate)
11
double taxOwed- 0;
taxOwed = (salary taxRate) / 180;
return taxOwed;
12
13
14
15
16
Run | Debug
public static void main(Strinc[] args) throws I0Exception
17
18
19
Arraylist<Double> salary - new Arraylist<Double>();
ArrayList<String> name - new ArrayList<String>();
Arraylist<String> company_name - new Arraylist<String>();
// int lines- 1;
20
21
22
23
24
try{
File myFile - new File(pathname: "taxpayer.txt");
Scanner fileReader- new Scanner (myFile);
25
26
Ln 5, Col 28 Spaces 4 UTF-8
O Mainjava X
Ftapayer.bt
Fuxintbt
O Mainjava>-
24
try{
File myFile - new File(pathname: "taxpayer.txt");
Scanner fileReader - new Scanner (myFile);
25
26
27
while(fileReader.hasNextline()){
28
String data - fileReader.nextLine();
29
System.out.printin(data);
String[] datahrr - data. split (regex: ", ");
name.add (dataarr[0] + " "+ dataArr[1] );
company_name.add (dataarr[2]);
double sal - Double.parseDouble(dataarr[3]);
salary.add(sal);
// if(lines X 3 -- 1 ){
30
31
32
33
34
35
36
//
name.add(data);
// Jelse if(lines % 3 -- 2){
//
// Jelse(
//
//
37
38
company_name. add(data);
39
40
double sal - Double.parseDouble(data);
41
salary.add (sal);
42
//)
43
// lines++;
44
45
filekeader.close();
46
}catch (FileNotFoundException e){
47
System.out.println(x: "File with given name not found");
e.printStackTrace();
48
49
}
50
Ln 5, Col 28 Spaces 4 UTF-8
O Mainjava X
F taxpayer t
Etaintbt
O Mainjava>.
48
e.printStackTrace();
49
50
try(Fileiriter myriter - new Filewriter(fileName: "taxinf.txt", append: true)
51
52
System.out.println(x: "Records started in file .....");
for (int i-0; i<name.size();i++)
53
54
55
String nameP- name.get (i);
String companyName- company_name.get (i);
double salaryP- salary.get(i);
double taxRate- 0, taxOwed- 0;
if(salary.get(i) <- 10000000) (
taxRate- 40;
Jelse(
taxRate- 53;
56
57
58
59
60
61
62
63
64
taxOwed - calcTax(salary.get (i), taxRate);
String tax - String.valueof (taxOwed);
myliriter.write (nameP+"\n" + companyName + "\n" +salaryP + "\n" + tax + "\n");
System.out.println(nameP+"\n"+companyName);
65
66
67
68
69
70
71
72 1
Transcribed Image Text:O Mainjaa> import java.io.File; import java.io.FileNotFoundException; import java.io.Filewriter; iport java.io.IOException; 1 2 3\ 4. import java.util.ArrayList; import java.util.Scanner; 7 public class Main { 10 static public double caleTax (double salary, double taxRate) 11 double taxOwed- 0; taxOwed = (salary taxRate) / 180; return taxOwed; 12 13 14 15 16 Run | Debug public static void main(Strinc[] args) throws I0Exception 17 18 19 Arraylist<Double> salary - new Arraylist<Double>(); ArrayList<String> name - new ArrayList<String>(); Arraylist<String> company_name - new Arraylist<String>(); // int lines- 1; 20 21 22 23 24 try{ File myFile - new File(pathname: "taxpayer.txt"); Scanner fileReader- new Scanner (myFile); 25 26 Ln 5, Col 28 Spaces 4 UTF-8 O Mainjava X Ftapayer.bt Fuxintbt O Mainjava>- 24 try{ File myFile - new File(pathname: "taxpayer.txt"); Scanner fileReader - new Scanner (myFile); 25 26 27 while(fileReader.hasNextline()){ 28 String data - fileReader.nextLine(); 29 System.out.printin(data); String[] datahrr - data. split (regex: ", "); name.add (dataarr[0] + " "+ dataArr[1] ); company_name.add (dataarr[2]); double sal - Double.parseDouble(dataarr[3]); salary.add(sal); // if(lines X 3 -- 1 ){ 30 31 32 33 34 35 36 // name.add(data); // Jelse if(lines % 3 -- 2){ // // Jelse( // // 37 38 company_name. add(data); 39 40 double sal - Double.parseDouble(data); 41 salary.add (sal); 42 //) 43 // lines++; 44 45 filekeader.close(); 46 }catch (FileNotFoundException e){ 47 System.out.println(x: "File with given name not found"); e.printStackTrace(); 48 49 } 50 Ln 5, Col 28 Spaces 4 UTF-8 O Mainjava X F taxpayer t Etaintbt O Mainjava>. 48 e.printStackTrace(); 49 50 try(Fileiriter myriter - new Filewriter(fileName: "taxinf.txt", append: true) 51 52 System.out.println(x: "Records started in file ....."); for (int i-0; i<name.size();i++) 53 54 55 String nameP- name.get (i); String companyName- company_name.get (i); double salaryP- salary.get(i); double taxRate- 0, taxOwed- 0; if(salary.get(i) <- 10000000) ( taxRate- 40; Jelse( taxRate- 53; 56 57 58 59 60 61 62 63 64 taxOwed - calcTax(salary.get (i), taxRate); String tax - String.valueof (taxOwed); myliriter.write (nameP+"\n" + companyName + "\n" +salaryP + "\n" + tax + "\n"); System.out.println(nameP+"\n"+companyName); 65 66 67 68 69 70 71 72 1
As a bonus, Revenue Canada is willing to pay more for your program if you were to display
the results on the screen as well. The display should look similar to:
Kevin Loughrey, Thompson Creek Metals Co. Inc. , $3,356,000.00 , $1,342,400.00
James Balsillie, Research In Motion Ltd., $141,594,333.00 , $75,044,996.49
Prem Watsa , Fairfax Financial Holdings Ltd. , $619,000.00 , $247,600.00
Richard Clark, Red Back Mining Inc. , $3,310,667.00 , $1,324,266.80
John Shackleton, Open Text Corp. , $4,861,667.00 , $1,944,666.80
John Wright, Petrobank Energy and Resources Ltd. , $4,353,333.00, $1,741,333.20
Transcribed Image Text:As a bonus, Revenue Canada is willing to pay more for your program if you were to display the results on the screen as well. The display should look similar to: Kevin Loughrey, Thompson Creek Metals Co. Inc. , $3,356,000.00 , $1,342,400.00 James Balsillie, Research In Motion Ltd., $141,594,333.00 , $75,044,996.49 Prem Watsa , Fairfax Financial Holdings Ltd. , $619,000.00 , $247,600.00 Richard Clark, Red Back Mining Inc. , $3,310,667.00 , $1,324,266.80 John Shackleton, Open Text Corp. , $4,861,667.00 , $1,944,666.80 John Wright, Petrobank Energy and Resources Ltd. , $4,353,333.00, $1,741,333.20
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY