Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions 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 ]
expand button
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
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
Check Mark
Knowledge Booster
Background pattern image
Similar questions
    SEE MORE QUESTIONS
    Recommended textbooks for you
    Text book image
    Computer Networking: A Top-Down Approach (7th Edi...
    Computer Engineering
    ISBN:9780133594140
    Author:James Kurose, Keith Ross
    Publisher:PEARSON
    Text book image
    Computer Organization and Design MIPS Edition, Fi...
    Computer Engineering
    ISBN:9780124077263
    Author:David A. Patterson, John L. Hennessy
    Publisher:Elsevier Science
    Text book image
    Network+ Guide to Networks (MindTap Course List)
    Computer Engineering
    ISBN:9781337569330
    Author:Jill West, Tamara Dean, Jean Andrews
    Publisher:Cengage Learning
    Text book image
    Concepts of Database Management
    Computer Engineering
    ISBN:9781337093422
    Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
    Publisher:Cengage Learning
    Text book image
    Prelude to Programming
    Computer Engineering
    ISBN:9780133750423
    Author:VENIT, Stewart
    Publisher:Pearson Education
    Text book image
    Sc Business Data Communications and Networking, T...
    Computer Engineering
    ISBN:9781119368830
    Author:FITZGERALD
    Publisher:WILEY