SlideShare a Scribd company logo
1 of 2
Download to read offline
Modify the Total program so that it writes the values in two columns, like this:
Previous answer Chegg provided displayed the correct output for in.txt but now, how do I make
the empty blank as shown?
Previous solution provided by Chegg:
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;
public class Total {
public static void main(String[] args) throws FileNotFoundException {
Scanner console = new Scanner(System.in);
System.out.print("Input file: ");
String inputFileName = console.next();
String outputFileName = "out.txt";
File inputFile = new File(inputFileName);
Scanner in = new Scanner(inputFile);
PrintWriter out = new PrintWriter(outputFileName);
double total = 0;
while (in.hasNext()) {
double value1 = in.hasNextDouble() ? in.nextDouble() : 0;
double value2 = in.hasNextDouble() ? in.nextDouble() : 0;
out.printf("%8.2f %7.2f%n", value1, value2);
total += (value1 + value2);
}
out.printf("Total: %10.2f%n", total);
in.close();
out.close();
}
} Your file content Your program produced no output Expected file content
1: Compare output Output differs. See highlights below. Special character legend 2: Compare
output A Input in2.txt

More Related Content

Similar to Modify the Total program so that it writes the values in two columns.pdf

Write a java program that allows the user to input the name of a fil.docx
 Write a java program that allows the user to input  the name of a fil.docx Write a java program that allows the user to input  the name of a fil.docx
Write a java program that allows the user to input the name of a fil.docxajoy21
 
Write a java program that allows the user to input the name of a file.docx
Write a java program that allows the user to input  the name of a file.docxWrite a java program that allows the user to input  the name of a file.docx
Write a java program that allows the user to input the name of a file.docxnoreendchesterton753
 
Java programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswarJava programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswarROHIT JAISWAR
 
The sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdfThe sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdfrajat630669
 
The sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdfThe sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdfrajat630669
 
CODEimport java.util.; public class test { public static voi.pdf
CODEimport java.util.; public class test { public static voi.pdfCODEimport java.util.; public class test { public static voi.pdf
CODEimport java.util.; public class test { public static voi.pdfanurag1231
 
Please help me with a UML class diagram for the following code im.pdf
Please help me with a UML class diagram for the following code im.pdfPlease help me with a UML class diagram for the following code im.pdf
Please help me with a UML class diagram for the following code im.pdfaioils
 
Write a program in java that asks a user for a file name and prints .pdf
Write a program in java that asks a user for a file name and prints .pdfWrite a program in java that asks a user for a file name and prints .pdf
Write a program in java that asks a user for a file name and prints .pdfatulkapoor33
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfmayorothenguyenhob69
 
Hi, I need help with a java programming project. specifically practi.pdf
Hi, I need help with a java programming project. specifically practi.pdfHi, I need help with a java programming project. specifically practi.pdf
Hi, I need help with a java programming project. specifically practi.pdfPRATIKSINHA7304
 
Advanced Java - Practical File
Advanced Java - Practical FileAdvanced Java - Practical File
Advanced Java - Practical FileFahad Shaikh
 
Important java programs(collection+file)
Important java programs(collection+file)Important java programs(collection+file)
Important java programs(collection+file)Alok Kumar
 
Anjalisoorej imca133 assignment
Anjalisoorej imca133 assignmentAnjalisoorej imca133 assignment
Anjalisoorej imca133 assignmentAnjaliSoorej
 

Similar to Modify the Total program so that it writes the values in two columns.pdf (20)

Write a java program that allows the user to input the name of a fil.docx
 Write a java program that allows the user to input  the name of a fil.docx Write a java program that allows the user to input  the name of a fil.docx
Write a java program that allows the user to input the name of a fil.docx
 
Write a java program that allows the user to input the name of a file.docx
Write a java program that allows the user to input  the name of a file.docxWrite a java program that allows the user to input  the name of a file.docx
Write a java program that allows the user to input the name of a file.docx
 
Java programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswarJava programming lab_manual_by_rohit_jaiswar
Java programming lab_manual_by_rohit_jaiswar
 
The sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdfThe sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdf
 
The sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdfThe sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdf
 
3.Lesson Plan - Input.pdf.pdf
3.Lesson Plan - Input.pdf.pdf3.Lesson Plan - Input.pdf.pdf
3.Lesson Plan - Input.pdf.pdf
 
CODEimport java.util.; public class test { public static voi.pdf
CODEimport java.util.; public class test { public static voi.pdfCODEimport java.util.; public class test { public static voi.pdf
CODEimport java.util.; public class test { public static voi.pdf
 
Code red SUM
Code red SUMCode red SUM
Code red SUM
 
Bhaloo
BhalooBhaloo
Bhaloo
 
Lab4
Lab4Lab4
Lab4
 
Please help me with a UML class diagram for the following code im.pdf
Please help me with a UML class diagram for the following code im.pdfPlease help me with a UML class diagram for the following code im.pdf
Please help me with a UML class diagram for the following code im.pdf
 
ExtraFileIO.pptx
ExtraFileIO.pptxExtraFileIO.pptx
ExtraFileIO.pptx
 
Write a program in java that asks a user for a file name and prints .pdf
Write a program in java that asks a user for a file name and prints .pdfWrite a program in java that asks a user for a file name and prints .pdf
Write a program in java that asks a user for a file name and prints .pdf
 
Programs of java
Programs of javaPrograms of java
Programs of java
 
Java practical
Java practicalJava practical
Java practical
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdf
 
Hi, I need help with a java programming project. specifically practi.pdf
Hi, I need help with a java programming project. specifically practi.pdfHi, I need help with a java programming project. specifically practi.pdf
Hi, I need help with a java programming project. specifically practi.pdf
 
Advanced Java - Practical File
Advanced Java - Practical FileAdvanced Java - Practical File
Advanced Java - Practical File
 
Important java programs(collection+file)
Important java programs(collection+file)Important java programs(collection+file)
Important java programs(collection+file)
 
Anjalisoorej imca133 assignment
Anjalisoorej imca133 assignmentAnjalisoorej imca133 assignment
Anjalisoorej imca133 assignment
 

More from saxenaavnish1

Mire el documental Am�rica se convierte en una potencia mundial, lea.pdf
Mire el documental Am�rica se convierte en una potencia mundial, lea.pdfMire el documental Am�rica se convierte en una potencia mundial, lea.pdf
Mire el documental Am�rica se convierte en una potencia mundial, lea.pdfsaxenaavnish1
 
Mini Case identificaci�n de los clientes adecuados para el ka de Fo.pdf
Mini Case identificaci�n de los clientes adecuados para el ka de Fo.pdfMini Case identificaci�n de los clientes adecuados para el ka de Fo.pdf
Mini Case identificaci�n de los clientes adecuados para el ka de Fo.pdfsaxenaavnish1
 
Millie Larsen es una mujer de 84 a�os que vive sola en una casa pequ.pdf
Millie Larsen es una mujer de 84 a�os que vive sola en una casa pequ.pdfMillie Larsen es una mujer de 84 a�os que vive sola en una casa pequ.pdf
Millie Larsen es una mujer de 84 a�os que vive sola en una casa pequ.pdfsaxenaavnish1
 
Miles, a 20 year old male, is seeking counseling because his paterna.pdf
Miles, a 20 year old male, is seeking counseling because his paterna.pdfMiles, a 20 year old male, is seeking counseling because his paterna.pdf
Miles, a 20 year old male, is seeking counseling because his paterna.pdfsaxenaavnish1
 
Mike s 3, p 2Leo s 2 , p 2Don s 1 , p 2April s 3 , p 1.pdf
Mike  s 3, p 2Leo  s 2 , p 2Don s 1 , p 2April  s 3 , p 1.pdfMike  s 3, p 2Leo  s 2 , p 2Don s 1 , p 2April  s 3 , p 1.pdf
Mike s 3, p 2Leo s 2 , p 2Don s 1 , p 2April s 3 , p 1.pdfsaxenaavnish1
 
Miguel is the managing general partner of MAR and owns a 40 interes.pdf
Miguel is the managing general partner of MAR and owns a 40 interes.pdfMiguel is the managing general partner of MAR and owns a 40 interes.pdf
Miguel is the managing general partner of MAR and owns a 40 interes.pdfsaxenaavnish1
 
Michael Porter de Harvard ha propuesto la cadena de valor como una h.pdf
Michael Porter de Harvard ha propuesto la cadena de valor como una h.pdfMichael Porter de Harvard ha propuesto la cadena de valor como una h.pdf
Michael Porter de Harvard ha propuesto la cadena de valor como una h.pdfsaxenaavnish1
 
Microbiology Describe the relationship between DNA and RNA con.pdf
Microbiology Describe the relationship between DNA and RNA con.pdfMicrobiology Describe the relationship between DNA and RNA con.pdf
Microbiology Describe the relationship between DNA and RNA con.pdfsaxenaavnish1
 
Michael leases a Lucerne farm to Boaz for a term of three years. Aft.pdf
Michael leases a Lucerne farm to Boaz for a term of three years. Aft.pdfMichael leases a Lucerne farm to Boaz for a term of three years. Aft.pdf
Michael leases a Lucerne farm to Boaz for a term of three years. Aft.pdfsaxenaavnish1
 
me quedan 35 munites por favor ayudenme Art�culo 1 En el caso .pdf
me quedan 35 munites por favor ayudenme Art�culo 1 En el caso .pdfme quedan 35 munites por favor ayudenme Art�culo 1 En el caso .pdf
me quedan 35 munites por favor ayudenme Art�culo 1 En el caso .pdfsaxenaavnish1
 
Mendel logr� descubrir las leyes b�sicas de la herencia, mientras qu.pdf
Mendel logr� descubrir las leyes b�sicas de la herencia, mientras qu.pdfMendel logr� descubrir las leyes b�sicas de la herencia, mientras qu.pdf
Mendel logr� descubrir las leyes b�sicas de la herencia, mientras qu.pdfsaxenaavnish1
 
MCQ Select the correct answer.1. What does SQL stand fora.pdf
MCQ  Select the correct answer.1. What does SQL stand fora.pdfMCQ  Select the correct answer.1. What does SQL stand fora.pdf
MCQ Select the correct answer.1. What does SQL stand fora.pdfsaxenaavnish1
 
MCQ Pls Help ACC495 Corporate Governance and Risk Management Which .pdf
MCQ Pls Help ACC495 Corporate Governance and Risk Management Which .pdfMCQ Pls Help ACC495 Corporate Governance and Risk Management Which .pdf
MCQ Pls Help ACC495 Corporate Governance and Risk Management Which .pdfsaxenaavnish1
 
Megan se gradu� de la universidad hace tres a�os y ha estado trabaja.pdf
Megan se gradu� de la universidad hace tres a�os y ha estado trabaja.pdfMegan se gradu� de la universidad hace tres a�os y ha estado trabaja.pdf
Megan se gradu� de la universidad hace tres a�os y ha estado trabaja.pdfsaxenaavnish1
 
media luna pura Sarah Ryan, vicepresidenta de marketing de Portlan.pdf
media luna pura Sarah Ryan, vicepresidenta de marketing de Portlan.pdfmedia luna pura Sarah Ryan, vicepresidenta de marketing de Portlan.pdf
media luna pura Sarah Ryan, vicepresidenta de marketing de Portlan.pdfsaxenaavnish1
 
my code doesnt work can you help me please the whole idea of is it i.pdf
my code doesnt work can you help me please the whole idea of is it i.pdfmy code doesnt work can you help me please the whole idea of is it i.pdf
my code doesnt work can you help me please the whole idea of is it i.pdfsaxenaavnish1
 
Must be in C++ programming The main objective of this experiment i.pdf
Must be in C++ programming The main objective of this experiment i.pdfMust be in C++ programming The main objective of this experiment i.pdf
Must be in C++ programming The main objective of this experiment i.pdfsaxenaavnish1
 
MUS monetary unit samplingA) What is the planned sample sizeB).pdf
MUS monetary unit samplingA) What is the planned sample sizeB).pdfMUS monetary unit samplingA) What is the planned sample sizeB).pdf
MUS monetary unit samplingA) What is the planned sample sizeB).pdfsaxenaavnish1
 
Multifactor authentication (MFA) requires users to authenticate thei.pdf
Multifactor authentication (MFA) requires users to authenticate thei.pdfMultifactor authentication (MFA) requires users to authenticate thei.pdf
Multifactor authentication (MFA) requires users to authenticate thei.pdfsaxenaavnish1
 
MTCR es una empresa l�der en el desarrollo y fabricaci�n de una ampl.pdf
MTCR es una empresa l�der en el desarrollo y fabricaci�n de una ampl.pdfMTCR es una empresa l�der en el desarrollo y fabricaci�n de una ampl.pdf
MTCR es una empresa l�der en el desarrollo y fabricaci�n de una ampl.pdfsaxenaavnish1
 

More from saxenaavnish1 (20)

Mire el documental Am�rica se convierte en una potencia mundial, lea.pdf
Mire el documental Am�rica se convierte en una potencia mundial, lea.pdfMire el documental Am�rica se convierte en una potencia mundial, lea.pdf
Mire el documental Am�rica se convierte en una potencia mundial, lea.pdf
 
Mini Case identificaci�n de los clientes adecuados para el ka de Fo.pdf
Mini Case identificaci�n de los clientes adecuados para el ka de Fo.pdfMini Case identificaci�n de los clientes adecuados para el ka de Fo.pdf
Mini Case identificaci�n de los clientes adecuados para el ka de Fo.pdf
 
Millie Larsen es una mujer de 84 a�os que vive sola en una casa pequ.pdf
Millie Larsen es una mujer de 84 a�os que vive sola en una casa pequ.pdfMillie Larsen es una mujer de 84 a�os que vive sola en una casa pequ.pdf
Millie Larsen es una mujer de 84 a�os que vive sola en una casa pequ.pdf
 
Miles, a 20 year old male, is seeking counseling because his paterna.pdf
Miles, a 20 year old male, is seeking counseling because his paterna.pdfMiles, a 20 year old male, is seeking counseling because his paterna.pdf
Miles, a 20 year old male, is seeking counseling because his paterna.pdf
 
Mike s 3, p 2Leo s 2 , p 2Don s 1 , p 2April s 3 , p 1.pdf
Mike  s 3, p 2Leo  s 2 , p 2Don s 1 , p 2April  s 3 , p 1.pdfMike  s 3, p 2Leo  s 2 , p 2Don s 1 , p 2April  s 3 , p 1.pdf
Mike s 3, p 2Leo s 2 , p 2Don s 1 , p 2April s 3 , p 1.pdf
 
Miguel is the managing general partner of MAR and owns a 40 interes.pdf
Miguel is the managing general partner of MAR and owns a 40 interes.pdfMiguel is the managing general partner of MAR and owns a 40 interes.pdf
Miguel is the managing general partner of MAR and owns a 40 interes.pdf
 
Michael Porter de Harvard ha propuesto la cadena de valor como una h.pdf
Michael Porter de Harvard ha propuesto la cadena de valor como una h.pdfMichael Porter de Harvard ha propuesto la cadena de valor como una h.pdf
Michael Porter de Harvard ha propuesto la cadena de valor como una h.pdf
 
Microbiology Describe the relationship between DNA and RNA con.pdf
Microbiology Describe the relationship between DNA and RNA con.pdfMicrobiology Describe the relationship between DNA and RNA con.pdf
Microbiology Describe the relationship between DNA and RNA con.pdf
 
Michael leases a Lucerne farm to Boaz for a term of three years. Aft.pdf
Michael leases a Lucerne farm to Boaz for a term of three years. Aft.pdfMichael leases a Lucerne farm to Boaz for a term of three years. Aft.pdf
Michael leases a Lucerne farm to Boaz for a term of three years. Aft.pdf
 
me quedan 35 munites por favor ayudenme Art�culo 1 En el caso .pdf
me quedan 35 munites por favor ayudenme Art�culo 1 En el caso .pdfme quedan 35 munites por favor ayudenme Art�culo 1 En el caso .pdf
me quedan 35 munites por favor ayudenme Art�culo 1 En el caso .pdf
 
Mendel logr� descubrir las leyes b�sicas de la herencia, mientras qu.pdf
Mendel logr� descubrir las leyes b�sicas de la herencia, mientras qu.pdfMendel logr� descubrir las leyes b�sicas de la herencia, mientras qu.pdf
Mendel logr� descubrir las leyes b�sicas de la herencia, mientras qu.pdf
 
MCQ Select the correct answer.1. What does SQL stand fora.pdf
MCQ  Select the correct answer.1. What does SQL stand fora.pdfMCQ  Select the correct answer.1. What does SQL stand fora.pdf
MCQ Select the correct answer.1. What does SQL stand fora.pdf
 
MCQ Pls Help ACC495 Corporate Governance and Risk Management Which .pdf
MCQ Pls Help ACC495 Corporate Governance and Risk Management Which .pdfMCQ Pls Help ACC495 Corporate Governance and Risk Management Which .pdf
MCQ Pls Help ACC495 Corporate Governance and Risk Management Which .pdf
 
Megan se gradu� de la universidad hace tres a�os y ha estado trabaja.pdf
Megan se gradu� de la universidad hace tres a�os y ha estado trabaja.pdfMegan se gradu� de la universidad hace tres a�os y ha estado trabaja.pdf
Megan se gradu� de la universidad hace tres a�os y ha estado trabaja.pdf
 
media luna pura Sarah Ryan, vicepresidenta de marketing de Portlan.pdf
media luna pura Sarah Ryan, vicepresidenta de marketing de Portlan.pdfmedia luna pura Sarah Ryan, vicepresidenta de marketing de Portlan.pdf
media luna pura Sarah Ryan, vicepresidenta de marketing de Portlan.pdf
 
my code doesnt work can you help me please the whole idea of is it i.pdf
my code doesnt work can you help me please the whole idea of is it i.pdfmy code doesnt work can you help me please the whole idea of is it i.pdf
my code doesnt work can you help me please the whole idea of is it i.pdf
 
Must be in C++ programming The main objective of this experiment i.pdf
Must be in C++ programming The main objective of this experiment i.pdfMust be in C++ programming The main objective of this experiment i.pdf
Must be in C++ programming The main objective of this experiment i.pdf
 
MUS monetary unit samplingA) What is the planned sample sizeB).pdf
MUS monetary unit samplingA) What is the planned sample sizeB).pdfMUS monetary unit samplingA) What is the planned sample sizeB).pdf
MUS monetary unit samplingA) What is the planned sample sizeB).pdf
 
Multifactor authentication (MFA) requires users to authenticate thei.pdf
Multifactor authentication (MFA) requires users to authenticate thei.pdfMultifactor authentication (MFA) requires users to authenticate thei.pdf
Multifactor authentication (MFA) requires users to authenticate thei.pdf
 
MTCR es una empresa l�der en el desarrollo y fabricaci�n de una ampl.pdf
MTCR es una empresa l�der en el desarrollo y fabricaci�n de una ampl.pdfMTCR es una empresa l�der en el desarrollo y fabricaci�n de una ampl.pdf
MTCR es una empresa l�der en el desarrollo y fabricaci�n de una ampl.pdf
 

Recently uploaded

psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxAmita Gupta
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 

Recently uploaded (20)

psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 

Modify the Total program so that it writes the values in two columns.pdf

  • 1. Modify the Total program so that it writes the values in two columns, like this: Previous answer Chegg provided displayed the correct output for in.txt but now, how do I make the empty blank as shown? Previous solution provided by Chegg: import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.Scanner; public class Total { public static void main(String[] args) throws FileNotFoundException { Scanner console = new Scanner(System.in); System.out.print("Input file: "); String inputFileName = console.next(); String outputFileName = "out.txt"; File inputFile = new File(inputFileName); Scanner in = new Scanner(inputFile); PrintWriter out = new PrintWriter(outputFileName); double total = 0; while (in.hasNext()) { double value1 = in.hasNextDouble() ? in.nextDouble() : 0; double value2 = in.hasNextDouble() ? in.nextDouble() : 0; out.printf("%8.2f %7.2f%n", value1, value2); total += (value1 + value2); } out.printf("Total: %10.2f%n", total); in.close(); out.close(); } } Your file content Your program produced no output Expected file content
  • 2. 1: Compare output Output differs. See highlights below. Special character legend 2: Compare output A Input in2.txt