SlideShare a Scribd company logo
1 of 2
Download to read offline
The Java Program for the above given is:
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Scanner;
import java.util.NoSuchElementException;
import java.io.PrintWriter;
public class InputPrototype
{
public static void main(String[] args)
throws FileNotFoundException
{
Scanner in = new Scanner(System.in);
System.out.print("Input File Name: ");
String inputFileName = in.next();
System.out.print("Output File Name: ");
String outputFileName = in.next();
File inputFile = new File(inputFileName);
Scanner input = new Scanner(inputFile);
PrintWriter out = new PrintWriter(outputFileName);
double total= 0;
while (in.hasNextDouble())
{
double value = in.nextDouble();
out.printf("%15.2f ", value);
total = total + value;
}
out.printf("Total: %8.2f ", total);
in.close();
out.close();
}
}
}
Solution
The Java Program for the above given is:
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Scanner;
import java.util.NoSuchElementException;
import java.io.PrintWriter;
public class InputPrototype
{
public static void main(String[] args)
throws FileNotFoundException
{
Scanner in = new Scanner(System.in);
System.out.print("Input File Name: ");
String inputFileName = in.next();
System.out.print("Output File Name: ");
String outputFileName = in.next();
File inputFile = new File(inputFileName);
Scanner input = new Scanner(inputFile);
PrintWriter out = new PrintWriter(outputFileName);
double total= 0;
while (in.hasNextDouble())
{
double value = in.nextDouble();
out.printf("%15.2f ", value);
total = total + value;
}
out.printf("Total: %8.2f ", total);
in.close();
out.close();
}
}
}

More Related Content

Similar to The Java Program for the above given isimport java.io.File;impo.pdf

import java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdfimport java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdf
manojmozy
 
Here is my code for a linefile editor import java.io.BufferedRea.pdf
Here is my code for a linefile editor import java.io.BufferedRea.pdfHere is my code for a linefile editor import java.io.BufferedRea.pdf
Here is my code for a linefile editor import java.io.BufferedRea.pdf
pratyushraj61
 
Below is my code for a line editor import java.io.BufferedReader;.pdf
Below is my code for a line editor import java.io.BufferedReader;.pdfBelow is my code for a line editor import java.io.BufferedReader;.pdf
Below is my code for a line editor import java.io.BufferedReader;.pdf
alankarshoe84
 
DisplayBook.java import java.io.File; import java.io.FileInput.pdf
DisplayBook.java import java.io.File; import java.io.FileInput.pdfDisplayBook.java import java.io.File; import java.io.FileInput.pdf
DisplayBook.java import java.io.File; import java.io.FileInput.pdf
sudheerforce
 
Write a Java program that opens the file, reads all the Grade from t.pdf
Write a Java program that opens the file, reads all the Grade from t.pdfWrite a Java program that opens the file, reads all the Grade from t.pdf
Write a Java program that opens the file, reads all the Grade from t.pdf
fashiionbeutycare
 
I can not get my code to comply it gets mad that I have run declare mo.docx
I can not get my code to comply it gets mad that I have run declare mo.docxI can not get my code to comply it gets mad that I have run declare mo.docx
I can not get my code to comply it gets mad that I have run declare mo.docx
hamblymarta
 
Java Program I keep receiving the following error in my code- Can you.pdf
Java Program I keep receiving the following error in my code- Can you.pdfJava Program I keep receiving the following error in my code- Can you.pdf
Java Program I keep receiving the following error in my code- Can you.pdf
RyanF2PLeev
 
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
aioils
 

Similar to The Java Program for the above given isimport java.io.File;impo.pdf (20)

Modify the Total program so that it writes the values in two columns.pdf
Modify the Total program so that it writes the values in two columns.pdfModify the Total program so that it writes the values in two columns.pdf
Modify the Total program so that it writes the values in two columns.pdf
 
import java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdfimport java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdf
 
JAVA Q2- Write a program that reads strings from the user and writes t.docx
JAVA Q2- Write a program that reads strings from the user and writes t.docxJAVA Q2- Write a program that reads strings from the user and writes t.docx
JAVA Q2- Write a program that reads strings from the user and writes t.docx
 
Here is my code for a linefile editor import java.io.BufferedRea.pdf
Here is my code for a linefile editor import java.io.BufferedRea.pdfHere is my code for a linefile editor import java.io.BufferedRea.pdf
Here is my code for a linefile editor import java.io.BufferedRea.pdf
 
Below is my code for a line editor import java.io.BufferedReader;.pdf
Below is my code for a line editor import java.io.BufferedReader;.pdfBelow is my code for a line editor import java.io.BufferedReader;.pdf
Below is my code for a line editor import java.io.BufferedReader;.pdf
 
DisplayBook.java import java.io.File; import java.io.FileInput.pdf
DisplayBook.java import java.io.File; import java.io.FileInput.pdfDisplayBook.java import java.io.File; import java.io.FileInput.pdf
DisplayBook.java import java.io.File; import java.io.FileInput.pdf
 
Write a Java program that opens the file, reads all the Grade from t.pdf
Write a Java program that opens the file, reads all the Grade from t.pdfWrite a Java program that opens the file, reads all the Grade from t.pdf
Write a Java program that opens the file, reads all the Grade from t.pdf
 
Factors.javaimport java.io.; import java.util.Scanner; class .pdf
Factors.javaimport java.io.; import java.util.Scanner; class .pdfFactors.javaimport java.io.; import java.util.Scanner; class .pdf
Factors.javaimport java.io.; import java.util.Scanner; class .pdf
 
I can not get my code to comply it gets mad that I have run declare mo.docx
I can not get my code to comply it gets mad that I have run declare mo.docxI can not get my code to comply it gets mad that I have run declare mo.docx
I can not get my code to comply it gets mad that I have run declare mo.docx
 
Write a program that will count the number of characters- words- and l.docx
Write a program that will count the number of characters- words- and l.docxWrite a program that will count the number of characters- words- and l.docx
Write a program that will count the number of characters- words- and l.docx
 
Java Program I keep receiving the following error in my code- Can you.pdf
Java Program I keep receiving the following error in my code- Can you.pdfJava Program I keep receiving the following error in my code- Can you.pdf
Java Program I keep receiving the following error in my code- Can you.pdf
 
File Handling.pptx
File Handling.pptxFile Handling.pptx
File Handling.pptx
 
54240326 (1)
54240326 (1)54240326 (1)
54240326 (1)
 
54240326 copy
54240326   copy54240326   copy
54240326 copy
 
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
 
2. Write a program which will open an input file and write to an out.pdf
2. Write a program which will open an input file and write to an out.pdf2. Write a program which will open an input file and write to an out.pdf
2. Write a program which will open an input file and write to an out.pdf
 
java input & output statements
 java input & output statements java input & output statements
java input & output statements
 
ExtraFileIO.pptx
ExtraFileIO.pptxExtraFileIO.pptx
ExtraFileIO.pptx
 
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
 

More from anjanacottonmills

This above plant name is Solidago sempervirens, belong to genus Soli.pdf
This above plant name is Solidago sempervirens, belong to genus Soli.pdfThis above plant name is Solidago sempervirens, belong to genus Soli.pdf
This above plant name is Solidago sempervirens, belong to genus Soli.pdf
anjanacottonmills
 
The fidelity of DNA replication determines the genome stability and .pdf
The fidelity of DNA replication determines the genome stability and .pdfThe fidelity of DNA replication determines the genome stability and .pdf
The fidelity of DNA replication determines the genome stability and .pdf
anjanacottonmills
 
The differences between ipv4 and ipv6 are as below1. Header1.Ch.pdf
The differences between ipv4 and ipv6 are as below1. Header1.Ch.pdfThe differences between ipv4 and ipv6 are as below1. Header1.Ch.pdf
The differences between ipv4 and ipv6 are as below1. Header1.Ch.pdf
anjanacottonmills
 
TCP - TCP breaks data into manageable packets and tracks information.pdf
TCP - TCP breaks data into manageable packets and tracks information.pdfTCP - TCP breaks data into manageable packets and tracks information.pdf
TCP - TCP breaks data into manageable packets and tracks information.pdf
anjanacottonmills
 
Static arrays are structures whose size is fixed at compile time and.pdf
Static arrays are structures whose size is fixed at compile time and.pdfStatic arrays are structures whose size is fixed at compile time and.pdf
Static arrays are structures whose size is fixed at compile time and.pdf
anjanacottonmills
 
NumberList.java (implements the linked list)public class NumberLis.pdf
NumberList.java (implements the linked list)public class NumberLis.pdfNumberList.java (implements the linked list)public class NumberLis.pdf
NumberList.java (implements the linked list)public class NumberLis.pdf
anjanacottonmills
 
In the above conversation it is belonging to stereotypes.Stereotyp.pdf
In the above conversation it is belonging to stereotypes.Stereotyp.pdfIn the above conversation it is belonging to stereotypes.Stereotyp.pdf
In the above conversation it is belonging to stereotypes.Stereotyp.pdf
anjanacottonmills
 
In general, the objective of an audit is to assess the risk of mater.pdf
In general, the objective of an audit is to assess the risk of mater.pdfIn general, the objective of an audit is to assess the risk of mater.pdf
In general, the objective of an audit is to assess the risk of mater.pdf
anjanacottonmills
 
if one can understand a few things it is easier to solve these kind .pdf
if one can understand a few things it is easier to solve these kind .pdfif one can understand a few things it is easier to solve these kind .pdf
if one can understand a few things it is easier to solve these kind .pdf
anjanacottonmills
 

More from anjanacottonmills (20)

Step1 First compound has 2 double bonds ; Second .pdf
                     Step1 First compound has 2 double bonds ; Second .pdf                     Step1 First compound has 2 double bonds ; Second .pdf
Step1 First compound has 2 double bonds ; Second .pdf
 
Molarity = molesvolume9liter) Molarity of NH4Cl.pdf
                     Molarity = molesvolume9liter)  Molarity of NH4Cl.pdf                     Molarity = molesvolume9liter)  Molarity of NH4Cl.pdf
Molarity = molesvolume9liter) Molarity of NH4Cl.pdf
 
HOCH2CH2OH is more soluble in water. more OH grou.pdf
                     HOCH2CH2OH is more soluble in water. more OH grou.pdf                     HOCH2CH2OH is more soluble in water. more OH grou.pdf
HOCH2CH2OH is more soluble in water. more OH grou.pdf
 
x = -2Solutionx = -2.pdf
x = -2Solutionx = -2.pdfx = -2Solutionx = -2.pdf
x = -2Solutionx = -2.pdf
 
z=(2n+1)4where n=all integersSolutionz=(2n+1)4where n=al.pdf
z=(2n+1)4where n=all integersSolutionz=(2n+1)4where n=al.pdfz=(2n+1)4where n=all integersSolutionz=(2n+1)4where n=al.pdf
z=(2n+1)4where n=all integersSolutionz=(2n+1)4where n=al.pdf
 
This above plant name is Solidago sempervirens, belong to genus Soli.pdf
This above plant name is Solidago sempervirens, belong to genus Soli.pdfThis above plant name is Solidago sempervirens, belong to genus Soli.pdf
This above plant name is Solidago sempervirens, belong to genus Soli.pdf
 
The fidelity of DNA replication determines the genome stability and .pdf
The fidelity of DNA replication determines the genome stability and .pdfThe fidelity of DNA replication determines the genome stability and .pdf
The fidelity of DNA replication determines the genome stability and .pdf
 
E= 0.28V reactants are favored .pdf
                     E= 0.28V reactants are favored                   .pdf                     E= 0.28V reactants are favored                   .pdf
E= 0.28V reactants are favored .pdf
 
The differences between ipv4 and ipv6 are as below1. Header1.Ch.pdf
The differences between ipv4 and ipv6 are as below1. Header1.Ch.pdfThe differences between ipv4 and ipv6 are as below1. Header1.Ch.pdf
The differences between ipv4 and ipv6 are as below1. Header1.Ch.pdf
 
TCP - TCP breaks data into manageable packets and tracks information.pdf
TCP - TCP breaks data into manageable packets and tracks information.pdfTCP - TCP breaks data into manageable packets and tracks information.pdf
TCP - TCP breaks data into manageable packets and tracks information.pdf
 
Static arrays are structures whose size is fixed at compile time and.pdf
Static arrays are structures whose size is fixed at compile time and.pdfStatic arrays are structures whose size is fixed at compile time and.pdf
Static arrays are structures whose size is fixed at compile time and.pdf
 
D) II, III, IV, and V only .pdf
                     D) II, III, IV, and V only                       .pdf                     D) II, III, IV, and V only                       .pdf
D) II, III, IV, and V only .pdf
 
NumberList.java (implements the linked list)public class NumberLis.pdf
NumberList.java (implements the linked list)public class NumberLis.pdfNumberList.java (implements the linked list)public class NumberLis.pdf
NumberList.java (implements the linked list)public class NumberLis.pdf
 
c) H2(g) + 12 O2(g) -H2O (l) as all are in the.pdf
                     c) H2(g) + 12 O2(g) -H2O (l)  as all are in the.pdf                     c) H2(g) + 12 O2(g) -H2O (l)  as all are in the.pdf
c) H2(g) + 12 O2(g) -H2O (l) as all are in the.pdf
 
MagicSquareTest.java import java.util.Scanner;public class Mag.pdf
MagicSquareTest.java import java.util.Scanner;public class Mag.pdfMagicSquareTest.java import java.util.Scanner;public class Mag.pdf
MagicSquareTest.java import java.util.Scanner;public class Mag.pdf
 
Interphase.This is the phase where the cell prepares for the next .pdf
Interphase.This is the phase where the cell prepares for the next .pdfInterphase.This is the phase where the cell prepares for the next .pdf
Interphase.This is the phase where the cell prepares for the next .pdf
 
B.the rotation will be zero as L and D will cance.pdf
                     B.the rotation will be zero as L and D will cance.pdf                     B.the rotation will be zero as L and D will cance.pdf
B.the rotation will be zero as L and D will cance.pdf
 
In the above conversation it is belonging to stereotypes.Stereotyp.pdf
In the above conversation it is belonging to stereotypes.Stereotyp.pdfIn the above conversation it is belonging to stereotypes.Stereotyp.pdf
In the above conversation it is belonging to stereotypes.Stereotyp.pdf
 
In general, the objective of an audit is to assess the risk of mater.pdf
In general, the objective of an audit is to assess the risk of mater.pdfIn general, the objective of an audit is to assess the risk of mater.pdf
In general, the objective of an audit is to assess the risk of mater.pdf
 
if one can understand a few things it is easier to solve these kind .pdf
if one can understand a few things it is easier to solve these kind .pdfif one can understand a few things it is easier to solve these kind .pdf
if one can understand a few things it is easier to solve these kind .pdf
 

Recently uploaded

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
AnaAcapella
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
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
 

Recently uploaded (20)

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
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
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
 
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.
 
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...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
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
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).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)
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
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...
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 

The Java Program for the above given isimport java.io.File;impo.pdf

  • 1. The Java Program for the above given is: import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Scanner; import java.util.NoSuchElementException; import java.io.PrintWriter; public class InputPrototype { public static void main(String[] args) throws FileNotFoundException { Scanner in = new Scanner(System.in); System.out.print("Input File Name: "); String inputFileName = in.next(); System.out.print("Output File Name: "); String outputFileName = in.next(); File inputFile = new File(inputFileName); Scanner input = new Scanner(inputFile); PrintWriter out = new PrintWriter(outputFileName); double total= 0; while (in.hasNextDouble()) { double value = in.nextDouble(); out.printf("%15.2f ", value); total = total + value; } out.printf("Total: %8.2f ", total); in.close(); out.close(); } } } Solution
  • 2. The Java Program for the above given is: import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Scanner; import java.util.NoSuchElementException; import java.io.PrintWriter; public class InputPrototype { public static void main(String[] args) throws FileNotFoundException { Scanner in = new Scanner(System.in); System.out.print("Input File Name: "); String inputFileName = in.next(); System.out.print("Output File Name: "); String outputFileName = in.next(); File inputFile = new File(inputFileName); Scanner input = new Scanner(inputFile); PrintWriter out = new PrintWriter(outputFileName); double total= 0; while (in.hasNextDouble()) { double value = in.nextDouble(); out.printf("%15.2f ", value); total = total + value; } out.printf("Total: %8.2f ", total); in.close(); out.close(); } } }