SlideShare a Scribd company logo
Write a program in Java that reads a set of doubles from a file, stores them in an array or
ArrayList, and then prints them back out to the console (using System.out.println statements) in
REVERSE order.
For example, if the input file input.txt file contains
27.3
45.6
98.3
10.1
The console output will display
10.1
98.3
45.6
27.3
Solution
ReadAndDisplayReverse.java
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;
public class ReadAndDisplayReverse {
public static void main(String[] args) throws FileNotFoundException {
File inputFile = new File("D:input.txt");
if(inputFile.exists()){
Scanner scan = new Scanner(inputFile);
ArrayList list = new ArrayList();
while(scan.hasNextDouble()){
list.add(scan.nextDouble());
}
System.out.println("The numbers in reverse order: ");
for(int i=list.size()-1; i>=0; i--){
System.out.println(list.get(i));
}
}
else{
System.out.println("Input file does not exist");
}
}
}
Output:
The numbers in reverse order:
10.1
98.3
45.6
27.3

More Related Content

Similar to Write a program in Java that reads a set of doubles from a file, sto.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
 
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
lez31palka
 
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
 
Create a text file named lnfo.txt. Enter the following informatio.pdf
Create a text file named lnfo.txt. Enter the following informatio.pdfCreate a text file named lnfo.txt. Enter the following informatio.pdf
Create a text file named lnfo.txt. Enter the following informatio.pdf
shahidqamar17
 
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
ajoy21
 
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
noreendchesterton753
 
Lab4
Lab4Lab4
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
 
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
 
import java.io.BufferedReader;import java.io.BufferedWriter;.docx
import java.io.BufferedReader;import java.io.BufferedWriter;.docximport java.io.BufferedReader;import java.io.BufferedWriter;.docx
import java.io.BufferedReader;import java.io.BufferedWriter;.docx
wilcockiris
 
Complete the following Java code such that it opens a file named Fruit.docx
Complete the following Java code such that it opens a file named Fruit.docxComplete the following Java code such that it opens a file named Fruit.docx
Complete the following Java code such that it opens a file named Fruit.docx
ljohn878
 
Packages and interfaces
Packages and interfacesPackages and interfaces
Packages and interfaces
bhuvaneshwariA5
 
In java , I want you to implement a Data Structure known as a Doubly.pdf
In java , I want you to implement a Data Structure known as a Doubly.pdfIn java , I want you to implement a Data Structure known as a Doubly.pdf
In java , I want you to implement a Data Structure known as a Doubly.pdf
aromalcom
 
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 ppt
Java pptJava ppt
Java ppt
Rohan Gajre
 
Write a java program that compute the frequency of each word in the fi.docx
Write a java program that compute the frequency of each word in the fi.docxWrite a java program that compute the frequency of each word in the fi.docx
Write a java program that compute the frequency of each word in the fi.docx
noreendchesterton753
 
JAVAWrite a program that takes a command-line argument representin.pdf
JAVAWrite a program that takes a command-line argument representin.pdfJAVAWrite a program that takes a command-line argument representin.pdf
JAVAWrite a program that takes a command-line argument representin.pdf
jibinsh
 
Lec2
Lec2Lec2
srgoc
srgocsrgoc

Similar to Write a program in Java that reads a set of doubles from a file, sto.pdf (20)

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
 
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
 
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
 
Create a text file named lnfo.txt. Enter the following informatio.pdf
Create a text file named lnfo.txt. Enter the following informatio.pdfCreate a text file named lnfo.txt. Enter the following informatio.pdf
Create a text file named lnfo.txt. Enter the following informatio.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.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
 
Lab4
Lab4Lab4
Lab4
 
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
 
Inheritance
InheritanceInheritance
Inheritance
 
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
 
import java.io.BufferedReader;import java.io.BufferedWriter;.docx
import java.io.BufferedReader;import java.io.BufferedWriter;.docximport java.io.BufferedReader;import java.io.BufferedWriter;.docx
import java.io.BufferedReader;import java.io.BufferedWriter;.docx
 
Complete the following Java code such that it opens a file named Fruit.docx
Complete the following Java code such that it opens a file named Fruit.docxComplete the following Java code such that it opens a file named Fruit.docx
Complete the following Java code such that it opens a file named Fruit.docx
 
Packages and interfaces
Packages and interfacesPackages and interfaces
Packages and interfaces
 
In java , I want you to implement a Data Structure known as a Doubly.pdf
In java , I want you to implement a Data Structure known as a Doubly.pdfIn java , I want you to implement a Data Structure known as a Doubly.pdf
In java , I want you to implement a Data Structure known as a Doubly.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
 
Java ppt
Java pptJava ppt
Java ppt
 
Write a java program that compute the frequency of each word in the fi.docx
Write a java program that compute the frequency of each word in the fi.docxWrite a java program that compute the frequency of each word in the fi.docx
Write a java program that compute the frequency of each word in the fi.docx
 
JAVAWrite a program that takes a command-line argument representin.pdf
JAVAWrite a program that takes a command-line argument representin.pdfJAVAWrite a program that takes a command-line argument representin.pdf
JAVAWrite a program that takes a command-line argument representin.pdf
 
Lec2
Lec2Lec2
Lec2
 
srgoc
srgocsrgoc
srgoc
 

More from arihantpatna

Compare and contrast the advantages and disadvantages of arrays and .pdf
Compare and contrast the advantages and disadvantages of arrays and .pdfCompare and contrast the advantages and disadvantages of arrays and .pdf
Compare and contrast the advantages and disadvantages of arrays and .pdf
arihantpatna
 
Answer and describe the following five plants habit, habitat, life .pdf
Answer and describe the following five plants habit, habitat, life .pdfAnswer and describe the following five plants habit, habitat, life .pdf
Answer and describe the following five plants habit, habitat, life .pdf
arihantpatna
 
A plant has the genotype (Aa; Bb; Cc). How many different genotype.pdf
A plant has the genotype (Aa; Bb; Cc). How many different genotype.pdfA plant has the genotype (Aa; Bb; Cc). How many different genotype.pdf
A plant has the genotype (Aa; Bb; Cc). How many different genotype.pdf
arihantpatna
 
A) Explain how bilateral symmetry contributed to motion and cephaliz.pdf
A) Explain how bilateral symmetry contributed to motion and cephaliz.pdfA) Explain how bilateral symmetry contributed to motion and cephaliz.pdf
A) Explain how bilateral symmetry contributed to motion and cephaliz.pdf
arihantpatna
 
_______ are any substances that when introduced into the body, stimul.pdf
_______ are any substances that when introduced into the body, stimul.pdf_______ are any substances that when introduced into the body, stimul.pdf
_______ are any substances that when introduced into the body, stimul.pdf
arihantpatna
 
You decide to spend Break hiking through the Rockies upon arrival, yo.pdf
You decide to spend Break hiking through the Rockies upon arrival, yo.pdfYou decide to spend Break hiking through the Rockies upon arrival, yo.pdf
You decide to spend Break hiking through the Rockies upon arrival, yo.pdf
arihantpatna
 
Which of the following statements is true about cultureA. Culture.pdf
Which of the following statements is true about cultureA. Culture.pdfWhich of the following statements is true about cultureA. Culture.pdf
Which of the following statements is true about cultureA. Culture.pdf
arihantpatna
 
Which data set has the least sample standard deviation Data set (ii.pdf
Which data set has the least sample standard deviation  Data set (ii.pdfWhich data set has the least sample standard deviation  Data set (ii.pdf
Which data set has the least sample standard deviation Data set (ii.pdf
arihantpatna
 
Whats wrong with this Hardy Weinberg question I thought it was a.pdf
Whats wrong with this Hardy Weinberg question I thought it was a.pdfWhats wrong with this Hardy Weinberg question I thought it was a.pdf
Whats wrong with this Hardy Weinberg question I thought it was a.pdf
arihantpatna
 
6. List and define the underlying conditions, or assumptions, which .pdf
6. List and define the underlying conditions, or assumptions, which .pdf6. List and define the underlying conditions, or assumptions, which .pdf
6. List and define the underlying conditions, or assumptions, which .pdf
arihantpatna
 
What does the LP tableau below indicate (The xs are decision varia.pdf
What does the LP tableau below indicate (The xs are decision varia.pdfWhat does the LP tableau below indicate (The xs are decision varia.pdf
What does the LP tableau below indicate (The xs are decision varia.pdf
arihantpatna
 
Wha is the difference between the large intestine and colon .pdf
Wha is the difference between the large intestine and colon .pdfWha is the difference between the large intestine and colon .pdf
Wha is the difference between the large intestine and colon .pdf
arihantpatna
 
Was airpower decisive in winning World War II Defend your answer..pdf
Was airpower decisive in winning World War II Defend your answer..pdfWas airpower decisive in winning World War II Defend your answer..pdf
Was airpower decisive in winning World War II Defend your answer..pdf
arihantpatna
 
Summarize the workflow of the study of microbial diversity. Draw a d.pdf
Summarize the workflow of the study of microbial diversity. Draw a d.pdfSummarize the workflow of the study of microbial diversity. Draw a d.pdf
Summarize the workflow of the study of microbial diversity. Draw a d.pdf
arihantpatna
 
Shifting allocations most often arise as a result of which of the fo.pdf
Shifting allocations most often arise as a result of which of the fo.pdfShifting allocations most often arise as a result of which of the fo.pdf
Shifting allocations most often arise as a result of which of the fo.pdf
arihantpatna
 
16.) How would you determine if Cellulous is hydrophobic or hydrophi.pdf
16.) How would you determine if Cellulous is hydrophobic or hydrophi.pdf16.) How would you determine if Cellulous is hydrophobic or hydrophi.pdf
16.) How would you determine if Cellulous is hydrophobic or hydrophi.pdf
arihantpatna
 
Please Explain CompletelyWhat defines the beginning of the hepatic.pdf
Please Explain CompletelyWhat defines the beginning of the hepatic.pdfPlease Explain CompletelyWhat defines the beginning of the hepatic.pdf
Please Explain CompletelyWhat defines the beginning of the hepatic.pdf
arihantpatna
 
Plant Diversity II –     Seed Plants1. Explain how the rise in pro.pdf
Plant Diversity II –     Seed Plants1. Explain how the rise in pro.pdfPlant Diversity II –     Seed Plants1. Explain how the rise in pro.pdf
Plant Diversity II –     Seed Plants1. Explain how the rise in pro.pdf
arihantpatna
 
17) Fill out the following table Structure Pili or Fimbriae Flagella.pdf
17) Fill out the following table Structure Pili or Fimbriae Flagella.pdf17) Fill out the following table Structure Pili or Fimbriae Flagella.pdf
17) Fill out the following table Structure Pili or Fimbriae Flagella.pdf
arihantpatna
 
Mark and I.isa registered for Physics 101 class. Mark attends class 6.pdf
Mark and I.isa registered for Physics 101 class. Mark attends class 6.pdfMark and I.isa registered for Physics 101 class. Mark attends class 6.pdf
Mark and I.isa registered for Physics 101 class. Mark attends class 6.pdf
arihantpatna
 

More from arihantpatna (20)

Compare and contrast the advantages and disadvantages of arrays and .pdf
Compare and contrast the advantages and disadvantages of arrays and .pdfCompare and contrast the advantages and disadvantages of arrays and .pdf
Compare and contrast the advantages and disadvantages of arrays and .pdf
 
Answer and describe the following five plants habit, habitat, life .pdf
Answer and describe the following five plants habit, habitat, life .pdfAnswer and describe the following five plants habit, habitat, life .pdf
Answer and describe the following five plants habit, habitat, life .pdf
 
A plant has the genotype (Aa; Bb; Cc). How many different genotype.pdf
A plant has the genotype (Aa; Bb; Cc). How many different genotype.pdfA plant has the genotype (Aa; Bb; Cc). How many different genotype.pdf
A plant has the genotype (Aa; Bb; Cc). How many different genotype.pdf
 
A) Explain how bilateral symmetry contributed to motion and cephaliz.pdf
A) Explain how bilateral symmetry contributed to motion and cephaliz.pdfA) Explain how bilateral symmetry contributed to motion and cephaliz.pdf
A) Explain how bilateral symmetry contributed to motion and cephaliz.pdf
 
_______ are any substances that when introduced into the body, stimul.pdf
_______ are any substances that when introduced into the body, stimul.pdf_______ are any substances that when introduced into the body, stimul.pdf
_______ are any substances that when introduced into the body, stimul.pdf
 
You decide to spend Break hiking through the Rockies upon arrival, yo.pdf
You decide to spend Break hiking through the Rockies upon arrival, yo.pdfYou decide to spend Break hiking through the Rockies upon arrival, yo.pdf
You decide to spend Break hiking through the Rockies upon arrival, yo.pdf
 
Which of the following statements is true about cultureA. Culture.pdf
Which of the following statements is true about cultureA. Culture.pdfWhich of the following statements is true about cultureA. Culture.pdf
Which of the following statements is true about cultureA. Culture.pdf
 
Which data set has the least sample standard deviation Data set (ii.pdf
Which data set has the least sample standard deviation  Data set (ii.pdfWhich data set has the least sample standard deviation  Data set (ii.pdf
Which data set has the least sample standard deviation Data set (ii.pdf
 
Whats wrong with this Hardy Weinberg question I thought it was a.pdf
Whats wrong with this Hardy Weinberg question I thought it was a.pdfWhats wrong with this Hardy Weinberg question I thought it was a.pdf
Whats wrong with this Hardy Weinberg question I thought it was a.pdf
 
6. List and define the underlying conditions, or assumptions, which .pdf
6. List and define the underlying conditions, or assumptions, which .pdf6. List and define the underlying conditions, or assumptions, which .pdf
6. List and define the underlying conditions, or assumptions, which .pdf
 
What does the LP tableau below indicate (The xs are decision varia.pdf
What does the LP tableau below indicate (The xs are decision varia.pdfWhat does the LP tableau below indicate (The xs are decision varia.pdf
What does the LP tableau below indicate (The xs are decision varia.pdf
 
Wha is the difference between the large intestine and colon .pdf
Wha is the difference between the large intestine and colon .pdfWha is the difference between the large intestine and colon .pdf
Wha is the difference between the large intestine and colon .pdf
 
Was airpower decisive in winning World War II Defend your answer..pdf
Was airpower decisive in winning World War II Defend your answer..pdfWas airpower decisive in winning World War II Defend your answer..pdf
Was airpower decisive in winning World War II Defend your answer..pdf
 
Summarize the workflow of the study of microbial diversity. Draw a d.pdf
Summarize the workflow of the study of microbial diversity. Draw a d.pdfSummarize the workflow of the study of microbial diversity. Draw a d.pdf
Summarize the workflow of the study of microbial diversity. Draw a d.pdf
 
Shifting allocations most often arise as a result of which of the fo.pdf
Shifting allocations most often arise as a result of which of the fo.pdfShifting allocations most often arise as a result of which of the fo.pdf
Shifting allocations most often arise as a result of which of the fo.pdf
 
16.) How would you determine if Cellulous is hydrophobic or hydrophi.pdf
16.) How would you determine if Cellulous is hydrophobic or hydrophi.pdf16.) How would you determine if Cellulous is hydrophobic or hydrophi.pdf
16.) How would you determine if Cellulous is hydrophobic or hydrophi.pdf
 
Please Explain CompletelyWhat defines the beginning of the hepatic.pdf
Please Explain CompletelyWhat defines the beginning of the hepatic.pdfPlease Explain CompletelyWhat defines the beginning of the hepatic.pdf
Please Explain CompletelyWhat defines the beginning of the hepatic.pdf
 
Plant Diversity II –     Seed Plants1. Explain how the rise in pro.pdf
Plant Diversity II –     Seed Plants1. Explain how the rise in pro.pdfPlant Diversity II –     Seed Plants1. Explain how the rise in pro.pdf
Plant Diversity II –     Seed Plants1. Explain how the rise in pro.pdf
 
17) Fill out the following table Structure Pili or Fimbriae Flagella.pdf
17) Fill out the following table Structure Pili or Fimbriae Flagella.pdf17) Fill out the following table Structure Pili or Fimbriae Flagella.pdf
17) Fill out the following table Structure Pili or Fimbriae Flagella.pdf
 
Mark and I.isa registered for Physics 101 class. Mark attends class 6.pdf
Mark and I.isa registered for Physics 101 class. Mark attends class 6.pdfMark and I.isa registered for Physics 101 class. Mark attends class 6.pdf
Mark and I.isa registered for Physics 101 class. Mark attends class 6.pdf
 

Recently uploaded

How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 

Recently uploaded (20)

How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 

Write a program in Java that reads a set of doubles from a file, sto.pdf

  • 1. Write a program in Java that reads a set of doubles from a file, stores them in an array or ArrayList, and then prints them back out to the console (using System.out.println statements) in REVERSE order. For example, if the input file input.txt file contains 27.3 45.6 98.3 10.1 The console output will display 10.1 98.3 45.6 27.3 Solution ReadAndDisplayReverse.java import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Scanner; public class ReadAndDisplayReverse { public static void main(String[] args) throws FileNotFoundException { File inputFile = new File("D:input.txt"); if(inputFile.exists()){ Scanner scan = new Scanner(inputFile); ArrayList list = new ArrayList(); while(scan.hasNextDouble()){ list.add(scan.nextDouble()); } System.out.println("The numbers in reverse order: "); for(int i=list.size()-1; i>=0; i--){ System.out.println(list.get(i));
  • 2. } } else{ System.out.println("Input file does not exist"); } } } Output: The numbers in reverse order: 10.1 98.3 45.6 27.3