Question

Question 1:
Write a program to read from a file “input4_01.txt” an integer N (0≤ N ≤ 100) and then read N double numbers from this file to an array. Write to file “output4_01.txt” the maximum number of the array. For example
File: “input4_01.txt”
5
1.30 2.22 4.00 17.60 3.14
File “output4_01.txt”
17.60


Question2: Write a program to read from a file “input4_02.txt” an integer N (0≤ N ≤ 100) and then read N double numbers from this file to an array. Write to file “output4_02.txt” this array but in the reverse order and also the sum of all elements in the array. For example
File: “input4_02.txt”
5
1.30 2.22 4.00 17.60 3.14
File “output4_02.txt”
3.14 17.60 4.00 2.22 1.30
Sum = 28.26

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.Scanner;

public class Question1 {

public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException
{
PrintWriter writer = new PrintWriter("output4_01.txt", "UTF-8");
Scanner input = new Scanner(new File("input4_01.txt"));
int count = input.nextInt();
double[] nums = new double[count];
double max = 0;
for(int i = 0; i < count; i++)
{...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Related Homework Solutions

Odd Numbers Problem in Java
Homework Solution
$10.00
Java
Programming
Computer Science
Mathematics
Integers
Odd Values
Even Values
Output
Input
Range
Loops
Conditions
Statements
Samples
Cylinder Containers in Java
Homework Solution
$25.00
Java
Programming
Codes
Algorithms
Computer Science
Statements
Variables
Loops
Input
Output
Integers
Strings
Geometry
Mathematics
Cylinder
Radius
Finance
Costs
Containers
Companies
Functions
Java Programming Assignment
Homework Solution
$30.00
Java Programming
Variables
ToString Method
Equals Method
Overload
Computer Science
Java Program And UML Diagram For Divers
Homework Solution
$20.00
Java
Programming
Computer Science
Coding
Divers
Testers
UML Diagram
Methods
Loops
Statements
Average Scores
Variables
Input Files
Output Files
Contest
Winner
Records
Data Sets
ChatBot Using Java Programming
Homework Solution
$7.00
Java
Programming
Coding
Chatting
Bot
Users
Computers
Sentences
Symbols
Instant Messaging
Input
Output
Special Characters
Even Numbers
Odd Numbers
5 Commandments For Computer Ethics
Homework Solution
$10.00
Computer Science
Programming
Commandments
Computer Ethics
Examples
Harm
Stealing Files
False Witness
Software
Resources
Authorization
Intellectual Output
Social Consequences
Respect
Get help from a qualified tutor
Live Chats