The Java program opens a file, reads grades within it, and uses a method to calculate and display:
1) The grades with their letter values (A, B, C, etc.)
2) The sum of all grades in the file
3) The average of all grades in the file
In JavaWrite a program that reads a text file that contains a gra.pdfmumnesh
In Java:
Write a program that reads a text file that contains a grade (for instance, 87) on each line.
Calculate and print the average of the grades.
Solution
import java.io.BufferedReader;
import java.io.FileReader; // importing filereader
import java.io.IOException; // importing file io exceptions
public class grade {
public static void main(String[] args) {
BufferedReader br = null;
double count=0;
int noOfgrades=0;
try {
String sLine;
br = new BufferedReader(new FileReader(\"sample.txt\")); // reading file using buffer
reader
while ((sLine = br.readLine()) != null) { // rading line by line
noOfgrades=noOfgrades+1; // getting number of grades
int num=Integer.parseInt(sLine); // convert string into integer
count=count+num; // adding each grade to count
}
System.out.println(\"count:\\t\"+count);
System.out.println(\"noOfgrades:\\t\"+noOfgrades);
System.out.println(\"Average of the grades:\\t\"+(count/noOfgrades));
} catch (IOException e) {
e.printStackTrace(); // catch exception
} finally {
try {
if (br != null)br.close(); // closing buffer
} catch (IOException ex) {
ex.printStackTrace();// printing exceptions
}
}
}
}
/********** out file******
fileName:sample.txt
file contains \"
23
34
56
7
88
89
52
34
65
\"
*/
/************output*************
count: 448.0
noOfgrades: 9
Average of the grades: 49.77
*/.
Use arrays to store data for analysis. Use functions to perform the .pdffootworld1
Use arrays to store data for analysis. Use functions to perform the analysis described below. All
output is to be written to an output file.
Solution
import java.util.Scanner;
import java.util.ArrayList;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
public class DNA{
private String dna;
public DNA(){
}
public void read_store(String filename){
/*try {
Scanner in;
//in = new Scanner(new FileReader(filename));
dna = in.next();
}catch(IOException e){
System.out.println(\"file not there \" + e);
return;
}*/
}
public char compliment_base(char c){
if(c == \'A\') return \'T\';
if(c == \'T\') return \'A\';
if(c == \'G\') return \'C\';
if(c == \'C\') return \'G\';
return \' \';
}
public void DrawDNA(String seq){
System.out.println(\"---+-----+------+------+------\");
for (char c : seq.toCharArray() ) {
System.out.print(c + \" \");
}
System.out.println(\"DNA Sequence \");
System.out.println(\"................................\");
for (char c : seq.toCharArray() ) {
System.out.print(compliment_base(c) + \" \");
}
System.out.println(\" Complement \");
System.out.println(\"---+-----+------+------+------\");
System.out.println(\"\");
}
public void Prefix(int n, String base){
String output = base.substring(0,n);
DrawDNA(output);
}
public static void main(String[] args) {
DNA d = new DNA();
d.DrawDNA(\"ATGC\");
d.Prefix(4,\"ACGTTGCA\");
}
}
---+-----+------+------+------
A T G C DNA Sequence
................................
T A C G Complement
---+-----+------+------+------
---+-----+------+------+------
A C G T DNA Sequence
................................
T G C A Complement
---+-----+------+------+------.
Write a program that will count the number of characters- words- and l.docxlez31palka
Write a program that will count the number of characters, words, and lines in a file. Words are separated by whitespace characters. The file name should be passed as a command-line argument, as shown;
c:\\exercise>java Exercise12_13 Loan.java
File Loan.java has
1919 characters
210 words
71 lines
c:\\exercise>
Solution
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.util.StringTokenizer;
public class ass1
{
public static void main(String[] args) throws FileNotFoundException
{
//Â Â Scanner console = new Scanner(System.in);
System.out.println(args[0]);
//System.out.println(args[1]);
//System.out.println(args[2]);
String inputFile=args[0];
File file = new File(inputFile);
Scanner in = new Scanner(file);
int words = 0;
int lines = 0;
int chars = 0;
while(in.hasNextLine()) {
lines++;
String line = in.nextLine();
chars += line.length();
words += new StringTokenizer(line, \" \").countTokens();
}
System.out.println(\"characters are \"+chars);
System.out.println(\"words are \"+words);
System.out.println(\"lines are \"+lines);
}
}
.
In JavaWrite a program that reads a text file that contains a gra.pdfmumnesh
In Java:
Write a program that reads a text file that contains a grade (for instance, 87) on each line.
Calculate and print the average of the grades.
Solution
import java.io.BufferedReader;
import java.io.FileReader; // importing filereader
import java.io.IOException; // importing file io exceptions
public class grade {
public static void main(String[] args) {
BufferedReader br = null;
double count=0;
int noOfgrades=0;
try {
String sLine;
br = new BufferedReader(new FileReader(\"sample.txt\")); // reading file using buffer
reader
while ((sLine = br.readLine()) != null) { // rading line by line
noOfgrades=noOfgrades+1; // getting number of grades
int num=Integer.parseInt(sLine); // convert string into integer
count=count+num; // adding each grade to count
}
System.out.println(\"count:\\t\"+count);
System.out.println(\"noOfgrades:\\t\"+noOfgrades);
System.out.println(\"Average of the grades:\\t\"+(count/noOfgrades));
} catch (IOException e) {
e.printStackTrace(); // catch exception
} finally {
try {
if (br != null)br.close(); // closing buffer
} catch (IOException ex) {
ex.printStackTrace();// printing exceptions
}
}
}
}
/********** out file******
fileName:sample.txt
file contains \"
23
34
56
7
88
89
52
34
65
\"
*/
/************output*************
count: 448.0
noOfgrades: 9
Average of the grades: 49.77
*/.
Use arrays to store data for analysis. Use functions to perform the .pdffootworld1
Use arrays to store data for analysis. Use functions to perform the analysis described below. All
output is to be written to an output file.
Solution
import java.util.Scanner;
import java.util.ArrayList;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
public class DNA{
private String dna;
public DNA(){
}
public void read_store(String filename){
/*try {
Scanner in;
//in = new Scanner(new FileReader(filename));
dna = in.next();
}catch(IOException e){
System.out.println(\"file not there \" + e);
return;
}*/
}
public char compliment_base(char c){
if(c == \'A\') return \'T\';
if(c == \'T\') return \'A\';
if(c == \'G\') return \'C\';
if(c == \'C\') return \'G\';
return \' \';
}
public void DrawDNA(String seq){
System.out.println(\"---+-----+------+------+------\");
for (char c : seq.toCharArray() ) {
System.out.print(c + \" \");
}
System.out.println(\"DNA Sequence \");
System.out.println(\"................................\");
for (char c : seq.toCharArray() ) {
System.out.print(compliment_base(c) + \" \");
}
System.out.println(\" Complement \");
System.out.println(\"---+-----+------+------+------\");
System.out.println(\"\");
}
public void Prefix(int n, String base){
String output = base.substring(0,n);
DrawDNA(output);
}
public static void main(String[] args) {
DNA d = new DNA();
d.DrawDNA(\"ATGC\");
d.Prefix(4,\"ACGTTGCA\");
}
}
---+-----+------+------+------
A T G C DNA Sequence
................................
T A C G Complement
---+-----+------+------+------
---+-----+------+------+------
A C G T DNA Sequence
................................
T G C A Complement
---+-----+------+------+------.
Write a program that will count the number of characters- words- and l.docxlez31palka
Write a program that will count the number of characters, words, and lines in a file. Words are separated by whitespace characters. The file name should be passed as a command-line argument, as shown;
c:\\exercise>java Exercise12_13 Loan.java
File Loan.java has
1919 characters
210 words
71 lines
c:\\exercise>
Solution
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.util.StringTokenizer;
public class ass1
{
public static void main(String[] args) throws FileNotFoundException
{
//Â Â Scanner console = new Scanner(System.in);
System.out.println(args[0]);
//System.out.println(args[1]);
//System.out.println(args[2]);
String inputFile=args[0];
File file = new File(inputFile);
Scanner in = new Scanner(file);
int words = 0;
int lines = 0;
int chars = 0;
while(in.hasNextLine()) {
lines++;
String line = in.nextLine();
chars += line.length();
words += new StringTokenizer(line, \" \").countTokens();
}
System.out.println(\"characters are \"+chars);
System.out.println(\"words are \"+words);
System.out.println(\"lines are \"+lines);
}
}
.
Write a java program that allows the user to input the name of a file.docxnoreendchesterton753
Write a java program that allows the user to input the name of a file that contains positive integers (one integer per line) The number of integers in the file The program should find all odd and even numbers and write the odd numbers to a file \"odd.txt\" and write the even numbers to another file \"even.txt\"
Solution
package expertques;
import java.io.File;
import java.io.PrintWriter;
import java.util.Scanner;
public class evenoddwithfile {
public static void main(String[] args) throws Exception {
File in;//file input
File even = new File(\"f://even.txt\");//creates file even
File odd = new File(\"f://odd.txt\");//creates file odd
Scanner s = new Scanner(System.in);//reads input from console or user
System.out.println(\"Enter the file name with path: \");
in = new File(s.nextLine());
System.out.println(\"Enter the number of integers n the file: \");
int n = s.nextInt();
if (in.exists()) {//checks if input file exist or not
Scanner ins = new Scanner(in);//reads input file
PrintWriter pe = new PrintWriter(even);//write to even file
PrintWriter po = new PrintWriter(odd);//writes to odd file
for (int i = 0; i < n; i++) {//loop till the numbers exists
int x = ins.nextInt();//reads from input file
if (x % 2 == 0) {//checks for even or odd
pe.println(x);//if even writes in even file
} else {
po.println(x);//if odd writes in odd file
}
}
pe.close();//closes even file very important else nothing will be written in the file
po.close();//closes odd file very important else nothing will be written in the file
System.out.println(\"File successfully written with odds and evens\");
} else {
System.out.println(\"Error file not found at specified path\");//if file not exist
}
}
}
output
run:
Enter the file name with path:
f://integers.txt
Enter the number of integers n the file:
8
File successfully written with odds and evens
BUILD SUCCESSFUL (total time: 6 seconds)
.
Write a java program that would ask the user to enter an input file .pdfudit652068
Write a java program that would ask the user to enter an input file name, and an output file name.
Then the program reads the content of the input file, and then writes the content of the input file
to the output file with each line proceeded with a line number followed by a colon. The line
numbering should start at 1.
should be used the following technique
(a) while loop should be used to complete the program.
(b)Scanner classisused
(c) PrintWriter class is used
(d) The files are closed before the program terminates.
ExampleOriginal Input fileOutput file with line number added1341: 1341252: 1251123:
1121894: 189
Solution
FileCopier.java:-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
public class FileCopier {
public static void main(String[] args) throws IOException{
Scanner in=new Scanner(System.in);
System.out.println(\"Enter input file\");
File inputFile=new File(in.nextLine());
if(!inputFile.exists()){
System.out.println(\"Source file doesn\'t exist\");
System.exit(0);
}
FileInputStream fis=new FileInputStream(inputFile);
System.out.println(\"Enter output file\");
FileWriter fw=new FileWriter(in.nextLine());
PrintWriter pw=new PrintWriter(fw);
in=new Scanner(inputFile);
int i=1;
while(in.hasNextLine()){
String s=in.nextLine();
pw.write(i++ + \": \" + s + \"\ \");
}
pw.flush();pw.close();
}
}
Console output:
Enter input file
test.txt
Enter output file
output.txt
Sample run 1:-
test.txt:
hey
123
.
howdy
output.txt:
1: hey
2: 123
3: .
4: howdy
Sample run 2:-
test.txt:
123
345
567
789
output.txt
1: 123
2: 345
3: 567
4: 789.
PAGE 1Input output for a file tutorialStreams and File IOI.docxalfred4lewis58146
PAGE
1Input output for a file tutorialStreams and File I/O
In this tutorial we study the following concepts:
Text File I/O
Techniques for a file: Class File
Binary File I/O
File Objects and File Name
Note: For question 4 of the midterm you only need to look at the sections 2.2 and 2.3. I do not think you need java class: StringTokenizer. But I just added a small section about it to the end of this tutorial.
So far we learned keyboard/screen I/O. It is time to learn File I/O.
1 An Overview of stream and file I/O
A stream is an object that either outputs data or inputs data. The Java System.out is a stream object that outputs data on the screen.
As our program gets bigger and bigger we may need to enter a lot of data every time we run our program. We also may have a lot of data as the output of the program. It is not practical to enter a sizable input from the keyboard. Therefore, we save the data in a file and let our program to input from this file. Similarly, it is not practical to look at a sizable output. Moreover, we may need to save the output for further study. Therefore, we let our program to output to a file.
We have two kinds of I/O files: Text files and binary files. A text file is readable and understandable by human, but a binary file is not. The size of a text file is bigger than the size of a binary file. We can write arrays without using a loop into a binary file. We can also write objects to a binary file.
2 Text-File I/O
In this section we learn how to input from a text file and how to output to a text file. We first look at output instructions for a text file.
2.1 Text-File Output with PrintWriter class.
To be able to write to a file we need the Java class PrintWriter. This class is in JDK java.io, therefore we need to import it . Another class that we need is : FileOutputStream. This class also is in java.io. A file output stream is an output stream for writing data to a File.
Example 1. The following program to write an integer, a floating point number, a Boolean value and a string into a text file.
import java. io. PrintWriter;
import java. io. FileNotFoundException;
publicclass Main {
publicstaticvoid main( String[] args) {
PrintWriter out = null;
try {
out = new PrintWriter("out.txt");
} catch( FileNotFoundException e) {
System. out. println("Error: opening the file out.txt");
System. exit( 0);
}
out.println(-12);
out.println(25.5);
out.println(true);
out.println("John Doe.");
//Note that we also can write:
out.println(-12+"\n"+ 25.5 + "\n" + true + "\n" + "John Doe.");
out.close();
} }
The content of the file out.txt would be:
-12
25.5
true
John Doe.
-12
25.5
true
John Doe.
Description:
First we need to declare a variable that refers to and object of class PrintWriter. This class has several constructors. One of them needs the name of the output file on the hard drive (or other storages): out = new PrintWriter("out.txt")
This instruction co.
Write a program in java that asks a user for a file name and prints .pdfatulkapoor33
Write a program in java that asks a user for a file name and prints the number of characters,
words (separated by whitespace), and lines in that file. Then, it replaces each line of the file with
its reverse. For example, if the file contains the following lines (Test1.txt):
This is a test
Hi there
Output on the console:
Number of characters: 22
Number of words: 6
Number of lines: 2
Data written to the file (Test1.txt):
tset a si sihT
ereth iH
Solution
ReadFileCount.java
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.util.Scanner;
public class ReadFileCount {
public static void main(String[] args) throws FileNotFoundException {
Scanner scan = new Scanner(System.in);
System.out.println(\"Enter file name: \");
String fileName = scan.next();
StringBuffer finalsb = new StringBuffer();
File file = new File(fileName);
if(file.exists()){
int numberOfLines = 0;
int numberOfCharacters = 0;
int numberOfWords = 0;
Scanner scan1 = new Scanner(file);;
while(scan1.hasNextLine()){
StringBuffer sb = new StringBuffer();
String s = scan1.nextLine();
sb.append(s);
numberOfLines++;
numberOfCharacters = numberOfCharacters + s.length();
String words[] = s.split(\" \");
numberOfWords = numberOfWords + words.length;
finalsb.append(sb.reverse());
finalsb.append(\"\ \");
}
System.out.println(\"Number of characters: \"+numberOfCharacters);
System.out.println(\"Number of words: \"+numberOfWords);
System.out.println(\"Number of lines : \"+numberOfLines);
PrintStream ps =new PrintStream(file);
ps.print(finalsb.toString());
ps.flush();
ps.close();
System.out.println(\"Data written to the file \"+fileName);
}
else{
System.out.println(\"File does not exist\");
}
}
}
Output:
Enter file name:
D:\\\\Test1.txt
Number of characters: 0
Number of words: 0
Number of lines : 0
Data written to the file D:\\\\Test1.txt
Test1.txt
tset a si sihT
ereht iH.
Exceptions, I/O and Threads Input and Output in Java: The File Class, Standard Streams, Keyboard
Input, File I/O Using Byte Streams, Character Streams, File I/O Using Character Streams -
Buffered Streams, File I/O Using a Buffered Stream, Keyboard Input Using a Buffered Stream,Writing Text Files. Threads: Threads vs. Processes, Creating Threads by Extending Thread,
Creating Threads by Implementing Runnable, Advantages of Using Threads, Daemon Threads,
Thread States, Thread Problems, Synchronization. Exceptions: Exception Handling, The Exception
Hierarchy, throws statement, throw statement, Developing user defined Exception Classes- The
finally Block.
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class FileEdit {
public static List lines = new ArrayList();
public static void main(String[] args) throws IOException
{
Scanner s = new Scanner(System.in);
System.out.print("EDIT: ");
String fileName = s.nextLine();
BufferedReader br = new BufferedReader(new FileReader(new File(fileName)));
String str="";
int count=0;
while((str=br.readLine())!=null)
{
lines.add(count, str);
System.out.println((++count) + "> "+ str);
}
String text="";
String command = "";
System.out.print((++count)+"> ");
command=s.nextLine();
String commandArr[];
int flag;
while(!command.equals("E"))
{
flag=0;
commandArr = command.split("\\s");
if(commandArr[0].equals("I")) //Insertion
{
while(true)
{
if(commandArr.length==1&&flag!=2)
{
System.out.print((count)+"> ");
text = s.nextLine();
insertLine(text,count-1);
}
else if(commandArr.length==2&&flag!=2)
{
System.out.print((commandArr[1])+"> ");
count=Integer.parseInt(commandArr[1]);
text = s.nextLine();
insertLine(text,Integer.parseInt(commandArr[1])-1);
}
else
insertLine(text,count-1);
System.out.print((++count)+"> ");
command=s.nextLine();
commandArr = command.split("\\s");
if(commandArr[0].equals("I")||commandArr[0].equals("L")||commandArr[0].equals("D")||comm
andArr[0].equals("E"))
{
flag=1;
break;
}
else
{
flag=2;
text=command;
}
}
}
else if(commandArr[0].equals("L")) //Listing
{
printList();
}
else if(commandArr[0].equals("D")) //Deletion
{
if(commandArr.length==1)
{
deleteLine(count-1,count-1);
}
else if(commandArr.length==2)
{
deleteLine(Integer.parseInt(commandArr[1])-1,Integer.parseInt(commandArr[1])-1);
}
else if(commandArr.length==3)
{
deleteLine(Integer.parseInt(commandArr[1])-1,Integer.parseInt(commandArr[2])-1);
}
count=lines.size();
}
if(flag!=1)
{
System.out.print((count++)+"> ");
command = s.nextLine();
}
}
}
public static void insertLine(String text,int count)
{
if (count >= lines.size()) {
for(int i = lines.size(); i <= count; i++) {
lines.add(null);
}
}
lines.set(count,text);
}
public static void deleteLine(int start,int end)
{
for(int i=start;i<=end;i++)
lines.remove(i);
}
public static void printList()
{
for(int i=0;i "+lines.get(i));
}
}
Here is my output:
EDIT: textin.txt
1> The First Line
1>
2> And another line
3> I 3
3> The second line
4> One more line
5> L
1> null
2> null
3> The second line
4> One more line
5> D 2
3> L
1> null
2> The second line
3> One more line
4> E
How can I keep it from printing "null" after ">" and it just be blank. I need the output to look like
this:
1> The first line
2>
3> And another line
4> I 3
3> The second line
4> One more line
5> L
1> The first line
2>
3> The second line
4> One more line
5> And another line
5> D 2
4> L
1> The first line
2> The second line
3> One more line
4> And another line
5> E.
Here is my code for a linefile editor import java.io.BufferedRea.pdfpratyushraj61
Here is my code for a line/file editor:
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class FileEdit {
public static List lines = new ArrayList();
public static void main(String[] args) throws IOException
{
Scanner s = new Scanner(System.in);
System.out.print("EDIT: ");
String fileName = s.nextLine();
BufferedReader br = new BufferedReader(new FileReader(new File(fileName)));
String str="";
int count=0;
while((str=br.readLine())!=null)
{
lines.add(count, str);
System.out.println((++count) + "> "+ str);
}
String text="";
String command = "";
System.out.print((++count)+"> ");
command=s.nextLine();
String commandArr[];
int flag;
while(!command.equals("E"))
{
flag=0;
commandArr = command.split("\\s");
if(commandArr[0].equals("I")) //Insertion
{
while(true)
{
if(commandArr.length==1&&flag!=2)
{
System.out.print((count)+"> ");
text = s.nextLine();
insertLine(text,count-1);
}
else if(commandArr.length==2&&flag!=2)
{
System.out.print((commandArr[1])+"> ");
count=Integer.parseInt(commandArr[1]);
text = s.nextLine();
insertLine(text,Integer.parseInt(commandArr[1])-1);
}
else
insertLine(text,count-1);
System.out.print((++count)+"> ");
command=s.nextLine();
commandArr = command.split("\\s");
if(commandArr[0].equals("I")||commandArr[0].equals("L")||commandArr[0].equals("D")||comm
andArr[0].equals("E"))
{
flag=1;
break;
}
else
{
flag=2;
text=command;
}
}
}
else if(commandArr[0].equals("L")) //Listing
{
printList();
}
else if(commandArr[0].equals("D")) //Deletion
{
if(commandArr.length==1)
{
deleteLine(count-1,count-1);
}
else if(commandArr.length==2)
{
deleteLine(Integer.parseInt(commandArr[1])-1,Integer.parseInt(commandArr[1])-1);
}
else if(commandArr.length==3)
{
deleteLine(Integer.parseInt(commandArr[1])-1,Integer.parseInt(commandArr[2])-1);
}
count=lines.size();
}
if(flag!=1)
{
System.out.print((count++)+"> ");
command = s.nextLine();
}
}
}
public static void insertLine(String text,int count)
{
if (count >= lines.size()) {
for(int i = lines.size(); i <= count; i++) {
lines.add(null);
}
}
lines.set(count,text);
}
public static void deleteLine(int start,int end)
{
for(int i=start;i<=end;i++)
lines.remove(i);
}
public static void printList()
{
for(int i=0;i "+lines.get(i));
}
}
Here is my output:
EDIT: textin.txt
1> The First Line
1>
2> And another line
3> I 3
3> The second line
4> One more line
5> L
1> null
2> null
3> The second line
4> One more line
5> D 2
3> L
1> null
2> The second line
3> One more line
4> E
How can I keep it from printing "null" after ">" and it just be blank. I need the output to look like
this:
1> The first line
2>
3> And another line
4> I 3
3> The second line
4> One more line
5> L
1> The first line
2>
3> The second line
4> One more line
5> And another line
5> D 2
4> L
1> The first line
2> The second line
3> One more line
4> And another line
5> E.
Core Java Programming Language (JSE) : Chapter XI - Console I/O and File I/OWebStackAcademy
Java.io.File Class in Java. The File class is Java's representation of a file or directory path name. ... A file system may implement restrictions to certain operations on the actual file-system object, such as reading, writing, and executing. These restrictions are collectively known as access permissions.
The program uses console I/O to simply read its "standard input (stdin)"—which might be the keyboard, a file dump, or the output of some other program—and print to its "standard output (stdout)"—which might be the display or printer or another program or a file.
JAVA Q2- Write a program that reads strings from the user and writes t.docxmichael1810
JAVA
Q2: Write a program that reads strings from the user and writes them to an output file called userStrings.txt. Stop processing when the user enters the string \"DONE\". Do not write the sentinel string (\"DONE\") to the output file. [15 points] Hint: For a complete example of file IO, please see the attached TestData program.
Sample Output:
A string.
Another string.
Yet more text...
DONE
Solution
Answer
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Scanner;
class WriteStringFile {
public static void main(String[] args) {
File file = new File(\"D:/userFile.txt\");
String data;
Scanner input = new Scanner(System.in);
data = input.readLine();
try (FileOutputStream fop = new FileOutputStream(file)) {
// if file doesn\'t exists, then create it
if (!file.exists()) {
file.createNewFile();
}
if (data != \"DONE\") {
// get the content in bytes
byte[] contentInBytes = content.getBytes();
fop.write(contentInBytes);
fop.flush();
fop.close();
} else {
System.out.println(\"User Enter the value Done.. So unable to write into file\");
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
.
Use Java to program the following.1. Create public java class name.pdff3apparelsonline
Use Java to program the following.
1. Create public java class named Benford.
2. It\'s main function should prompt for the name of a data file and then the function iterates
through the all of the elements in the data file and computes the frequency (count and
percentage) of the first number in each entry.
3. Note: Some of the data files have comments that you must filter out.
4. Also note: that blank lines or lines where the number begins or is 0 must also be filtered out.
5. Your output must be formatted as follows.
Solution
Hi Firend, Please find my code.
Please let me know in case of any issue.
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class CountFrequency {
public static void main(String[] args) throws FileNotFoundException {
Scanner sc = new Scanner(System.in);
// taking input file name
System.out.print(\"Enter input file name: \");
String fileName = sc.next();
// opening input file
Scanner inputFile = new Scanner(new File(fileName));
// declaring array to store count of first digit of each entery
int[] frequency = new int[10];
int totalCount = 0; // to maintain total count
int num;
// reading all lines
while(inputFile.hasNextLine()){
// reading current line
String line = inputFile.nextLine();
// if line is not empty
if(line == null || line.isEmpty() || line.trim() == \"\")
continue;
// taking first character of current line
char firstDigit = line.charAt(0);
// if first character is digit and not equal to 0
if(Character.isDigit(firstDigit) && firstDigit != \'0\'){
// converting first character of current line in integer
int d = firstDigit - \'0\';
frequency[d]++;
totalCount++;
}
}
System.out.println(\"Digit\\tCount\\tFrequency\");
for(int i=1; i<=9; i++){
System.out.println(i+\"\\t\"+frequency[i]+\"\\t\"+
((double)frequency[i]/(double)totalCount*100));
}
}
}
/*
Sample run:
##### Entry of input.txt:
453 43
//543
123
0
4ee
875
52
// Output
Enter input file name: input.txt
Digit Count Frequency
1 1 20.0
2 0 0.0
3 0 0.0
4 2 40.0
5 1 20.0
6 0 0.0
7 0 0.0
8 1 20.0
9 0 0.0
*/.
Change the code in Writer.java only to get it working. Must contain .pdfsecunderbadtirumalgi
Change the code in Writer.java only to get it working. Must contain methods: logReverse() ,
logMax(), logDuplicates(),
This lab is going to focus on File Output, which you will find is somewhat similar to console
output.
FileMain.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
public class FileMain {
public static void main(String[] args) throws IOException{
Scanner scnr = new Scanner(System.in);
System.out.print("Please enter the name of the file you would like to read: ");
String fileName = scnr.next();
Reader reader = new Reader();
ArrayList fileContents = reader.getFileContents(fileName);
System.out.println("Please enter a name for your new file: ");
String newFileName = scnr.next();
Writer fileOut = new Writer(newFileName);
fileOut.logReverse(fileContents);
fileOut.logMax(fileContents);
fileOut.logDuplicates(fileContents);
fileOut.closeWriter();
scnr.close();
}
}
Filetester.java
import java.io.IOException;
import java.util.ArrayList;
public class FileTester {
public static boolean testLogReverse(ArrayList contents) throws IOException {
Writer writer = new Writer("logReverseTest.txt");
writer.logReverse(contents);
writer.closeWriter();
ArrayList expected = new ArrayList();
expected.add("Reversed file contents: ");
expected.add("58");
expected.add("12");
expected.add("19");
expected.add("42");
expected.add("12");
expected.add("End of file.");
Reader testReader = new Reader();
ArrayList result = testReader.getFileContents("logReverseTest.txt");
if(expected.equals(result)) return true;
else return false;
}
public static boolean testLogMax(ArrayList contents) throws IOException {
Writer writer = new Writer("logMaxTest.txt");
writer.logMax(contents);
writer.closeWriter();
ArrayList expected = new ArrayList();
expected.add("The largest number in the file is: 58");
expected.add("End of file.");
Reader testReader = new Reader();
ArrayList result = testReader.getFileContents("logMaxTest.txt");
if(expected.equals(result)) return true;
else return false;
}
public static boolean testLogDuplicates(ArrayList contents) throws IOException {
Writer writer = new Writer("logDuplicatesTest.txt");
writer.logDuplicates(contents);
writer.closeWriter();
ArrayList expected = new ArrayList();
expected.add("Duplicates found: true");
expected.add("End of file.");
Reader testReader = new Reader();
ArrayList result = testReader.getFileContents("logDuplicatesTest.txt");
if(expected.equals(result)) return true;
else return false;
}
public static void main(String[] args) throws IOException {
Reader reader = new Reader();
ArrayList fileContents = reader.getFileContents("nums.txt");
System.out.println("logReverse test passed? " + testLogReverse(fileContents));
System.out.println("logMax test passed? " + testLogMax(fileContents));
System.out.println("logDuplicates test passed? " + testLogDuplicates(fileContents));
}
}
Reader.java
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Sca.
________ are characterized by small incisors and large premolars wit.pdffashiionbeutycare
________ are characterized by small incisors and large premolars with sharp crests.
a. Insectivores
b. Folivores
c. Faunivores
d. Frugivores
Solution
Folivores are characterized by small incisors and large premolar with sharp crest
Because they are basically herbivores taking cellulose rich leafs and plant stems so they need
proper chewing for digesting that.
Because of that usually they have large premolar and molar teeth and small or no incisors teeth..
why do Private offices have a high sensible heat ratioSolution.pdffashiionbeutycare
why do Private offices have a high sensible heat ratio?
Solution
the private offives where the high concentration is demanded the high sensible heat ratio is
because to maintain the humidity in summer
SHR=SENSIBLE HEAT/TOTAL HEAT so if sensible heat ratio will high then total heat will
low and so in office temperature is maintain.
More Related Content
Similar to Write a Java program that opens the file, reads all the Grade from t.pdf
Write a java program that allows the user to input the name of a file.docxnoreendchesterton753
Write a java program that allows the user to input the name of a file that contains positive integers (one integer per line) The number of integers in the file The program should find all odd and even numbers and write the odd numbers to a file \"odd.txt\" and write the even numbers to another file \"even.txt\"
Solution
package expertques;
import java.io.File;
import java.io.PrintWriter;
import java.util.Scanner;
public class evenoddwithfile {
public static void main(String[] args) throws Exception {
File in;//file input
File even = new File(\"f://even.txt\");//creates file even
File odd = new File(\"f://odd.txt\");//creates file odd
Scanner s = new Scanner(System.in);//reads input from console or user
System.out.println(\"Enter the file name with path: \");
in = new File(s.nextLine());
System.out.println(\"Enter the number of integers n the file: \");
int n = s.nextInt();
if (in.exists()) {//checks if input file exist or not
Scanner ins = new Scanner(in);//reads input file
PrintWriter pe = new PrintWriter(even);//write to even file
PrintWriter po = new PrintWriter(odd);//writes to odd file
for (int i = 0; i < n; i++) {//loop till the numbers exists
int x = ins.nextInt();//reads from input file
if (x % 2 == 0) {//checks for even or odd
pe.println(x);//if even writes in even file
} else {
po.println(x);//if odd writes in odd file
}
}
pe.close();//closes even file very important else nothing will be written in the file
po.close();//closes odd file very important else nothing will be written in the file
System.out.println(\"File successfully written with odds and evens\");
} else {
System.out.println(\"Error file not found at specified path\");//if file not exist
}
}
}
output
run:
Enter the file name with path:
f://integers.txt
Enter the number of integers n the file:
8
File successfully written with odds and evens
BUILD SUCCESSFUL (total time: 6 seconds)
.
Write a java program that would ask the user to enter an input file .pdfudit652068
Write a java program that would ask the user to enter an input file name, and an output file name.
Then the program reads the content of the input file, and then writes the content of the input file
to the output file with each line proceeded with a line number followed by a colon. The line
numbering should start at 1.
should be used the following technique
(a) while loop should be used to complete the program.
(b)Scanner classisused
(c) PrintWriter class is used
(d) The files are closed before the program terminates.
ExampleOriginal Input fileOutput file with line number added1341: 1341252: 1251123:
1121894: 189
Solution
FileCopier.java:-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
public class FileCopier {
public static void main(String[] args) throws IOException{
Scanner in=new Scanner(System.in);
System.out.println(\"Enter input file\");
File inputFile=new File(in.nextLine());
if(!inputFile.exists()){
System.out.println(\"Source file doesn\'t exist\");
System.exit(0);
}
FileInputStream fis=new FileInputStream(inputFile);
System.out.println(\"Enter output file\");
FileWriter fw=new FileWriter(in.nextLine());
PrintWriter pw=new PrintWriter(fw);
in=new Scanner(inputFile);
int i=1;
while(in.hasNextLine()){
String s=in.nextLine();
pw.write(i++ + \": \" + s + \"\ \");
}
pw.flush();pw.close();
}
}
Console output:
Enter input file
test.txt
Enter output file
output.txt
Sample run 1:-
test.txt:
hey
123
.
howdy
output.txt:
1: hey
2: 123
3: .
4: howdy
Sample run 2:-
test.txt:
123
345
567
789
output.txt
1: 123
2: 345
3: 567
4: 789.
PAGE 1Input output for a file tutorialStreams and File IOI.docxalfred4lewis58146
PAGE
1Input output for a file tutorialStreams and File I/O
In this tutorial we study the following concepts:
Text File I/O
Techniques for a file: Class File
Binary File I/O
File Objects and File Name
Note: For question 4 of the midterm you only need to look at the sections 2.2 and 2.3. I do not think you need java class: StringTokenizer. But I just added a small section about it to the end of this tutorial.
So far we learned keyboard/screen I/O. It is time to learn File I/O.
1 An Overview of stream and file I/O
A stream is an object that either outputs data or inputs data. The Java System.out is a stream object that outputs data on the screen.
As our program gets bigger and bigger we may need to enter a lot of data every time we run our program. We also may have a lot of data as the output of the program. It is not practical to enter a sizable input from the keyboard. Therefore, we save the data in a file and let our program to input from this file. Similarly, it is not practical to look at a sizable output. Moreover, we may need to save the output for further study. Therefore, we let our program to output to a file.
We have two kinds of I/O files: Text files and binary files. A text file is readable and understandable by human, but a binary file is not. The size of a text file is bigger than the size of a binary file. We can write arrays without using a loop into a binary file. We can also write objects to a binary file.
2 Text-File I/O
In this section we learn how to input from a text file and how to output to a text file. We first look at output instructions for a text file.
2.1 Text-File Output with PrintWriter class.
To be able to write to a file we need the Java class PrintWriter. This class is in JDK java.io, therefore we need to import it . Another class that we need is : FileOutputStream. This class also is in java.io. A file output stream is an output stream for writing data to a File.
Example 1. The following program to write an integer, a floating point number, a Boolean value and a string into a text file.
import java. io. PrintWriter;
import java. io. FileNotFoundException;
publicclass Main {
publicstaticvoid main( String[] args) {
PrintWriter out = null;
try {
out = new PrintWriter("out.txt");
} catch( FileNotFoundException e) {
System. out. println("Error: opening the file out.txt");
System. exit( 0);
}
out.println(-12);
out.println(25.5);
out.println(true);
out.println("John Doe.");
//Note that we also can write:
out.println(-12+"\n"+ 25.5 + "\n" + true + "\n" + "John Doe.");
out.close();
} }
The content of the file out.txt would be:
-12
25.5
true
John Doe.
-12
25.5
true
John Doe.
Description:
First we need to declare a variable that refers to and object of class PrintWriter. This class has several constructors. One of them needs the name of the output file on the hard drive (or other storages): out = new PrintWriter("out.txt")
This instruction co.
Write a program in java that asks a user for a file name and prints .pdfatulkapoor33
Write a program in java that asks a user for a file name and prints the number of characters,
words (separated by whitespace), and lines in that file. Then, it replaces each line of the file with
its reverse. For example, if the file contains the following lines (Test1.txt):
This is a test
Hi there
Output on the console:
Number of characters: 22
Number of words: 6
Number of lines: 2
Data written to the file (Test1.txt):
tset a si sihT
ereth iH
Solution
ReadFileCount.java
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.util.Scanner;
public class ReadFileCount {
public static void main(String[] args) throws FileNotFoundException {
Scanner scan = new Scanner(System.in);
System.out.println(\"Enter file name: \");
String fileName = scan.next();
StringBuffer finalsb = new StringBuffer();
File file = new File(fileName);
if(file.exists()){
int numberOfLines = 0;
int numberOfCharacters = 0;
int numberOfWords = 0;
Scanner scan1 = new Scanner(file);;
while(scan1.hasNextLine()){
StringBuffer sb = new StringBuffer();
String s = scan1.nextLine();
sb.append(s);
numberOfLines++;
numberOfCharacters = numberOfCharacters + s.length();
String words[] = s.split(\" \");
numberOfWords = numberOfWords + words.length;
finalsb.append(sb.reverse());
finalsb.append(\"\ \");
}
System.out.println(\"Number of characters: \"+numberOfCharacters);
System.out.println(\"Number of words: \"+numberOfWords);
System.out.println(\"Number of lines : \"+numberOfLines);
PrintStream ps =new PrintStream(file);
ps.print(finalsb.toString());
ps.flush();
ps.close();
System.out.println(\"Data written to the file \"+fileName);
}
else{
System.out.println(\"File does not exist\");
}
}
}
Output:
Enter file name:
D:\\\\Test1.txt
Number of characters: 0
Number of words: 0
Number of lines : 0
Data written to the file D:\\\\Test1.txt
Test1.txt
tset a si sihT
ereht iH.
Exceptions, I/O and Threads Input and Output in Java: The File Class, Standard Streams, Keyboard
Input, File I/O Using Byte Streams, Character Streams, File I/O Using Character Streams -
Buffered Streams, File I/O Using a Buffered Stream, Keyboard Input Using a Buffered Stream,Writing Text Files. Threads: Threads vs. Processes, Creating Threads by Extending Thread,
Creating Threads by Implementing Runnable, Advantages of Using Threads, Daemon Threads,
Thread States, Thread Problems, Synchronization. Exceptions: Exception Handling, The Exception
Hierarchy, throws statement, throw statement, Developing user defined Exception Classes- The
finally Block.
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class FileEdit {
public static List lines = new ArrayList();
public static void main(String[] args) throws IOException
{
Scanner s = new Scanner(System.in);
System.out.print("EDIT: ");
String fileName = s.nextLine();
BufferedReader br = new BufferedReader(new FileReader(new File(fileName)));
String str="";
int count=0;
while((str=br.readLine())!=null)
{
lines.add(count, str);
System.out.println((++count) + "> "+ str);
}
String text="";
String command = "";
System.out.print((++count)+"> ");
command=s.nextLine();
String commandArr[];
int flag;
while(!command.equals("E"))
{
flag=0;
commandArr = command.split("\\s");
if(commandArr[0].equals("I")) //Insertion
{
while(true)
{
if(commandArr.length==1&&flag!=2)
{
System.out.print((count)+"> ");
text = s.nextLine();
insertLine(text,count-1);
}
else if(commandArr.length==2&&flag!=2)
{
System.out.print((commandArr[1])+"> ");
count=Integer.parseInt(commandArr[1]);
text = s.nextLine();
insertLine(text,Integer.parseInt(commandArr[1])-1);
}
else
insertLine(text,count-1);
System.out.print((++count)+"> ");
command=s.nextLine();
commandArr = command.split("\\s");
if(commandArr[0].equals("I")||commandArr[0].equals("L")||commandArr[0].equals("D")||comm
andArr[0].equals("E"))
{
flag=1;
break;
}
else
{
flag=2;
text=command;
}
}
}
else if(commandArr[0].equals("L")) //Listing
{
printList();
}
else if(commandArr[0].equals("D")) //Deletion
{
if(commandArr.length==1)
{
deleteLine(count-1,count-1);
}
else if(commandArr.length==2)
{
deleteLine(Integer.parseInt(commandArr[1])-1,Integer.parseInt(commandArr[1])-1);
}
else if(commandArr.length==3)
{
deleteLine(Integer.parseInt(commandArr[1])-1,Integer.parseInt(commandArr[2])-1);
}
count=lines.size();
}
if(flag!=1)
{
System.out.print((count++)+"> ");
command = s.nextLine();
}
}
}
public static void insertLine(String text,int count)
{
if (count >= lines.size()) {
for(int i = lines.size(); i <= count; i++) {
lines.add(null);
}
}
lines.set(count,text);
}
public static void deleteLine(int start,int end)
{
for(int i=start;i<=end;i++)
lines.remove(i);
}
public static void printList()
{
for(int i=0;i "+lines.get(i));
}
}
Here is my output:
EDIT: textin.txt
1> The First Line
1>
2> And another line
3> I 3
3> The second line
4> One more line
5> L
1> null
2> null
3> The second line
4> One more line
5> D 2
3> L
1> null
2> The second line
3> One more line
4> E
How can I keep it from printing "null" after ">" and it just be blank. I need the output to look like
this:
1> The first line
2>
3> And another line
4> I 3
3> The second line
4> One more line
5> L
1> The first line
2>
3> The second line
4> One more line
5> And another line
5> D 2
4> L
1> The first line
2> The second line
3> One more line
4> And another line
5> E.
Here is my code for a linefile editor import java.io.BufferedRea.pdfpratyushraj61
Here is my code for a line/file editor:
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class FileEdit {
public static List lines = new ArrayList();
public static void main(String[] args) throws IOException
{
Scanner s = new Scanner(System.in);
System.out.print("EDIT: ");
String fileName = s.nextLine();
BufferedReader br = new BufferedReader(new FileReader(new File(fileName)));
String str="";
int count=0;
while((str=br.readLine())!=null)
{
lines.add(count, str);
System.out.println((++count) + "> "+ str);
}
String text="";
String command = "";
System.out.print((++count)+"> ");
command=s.nextLine();
String commandArr[];
int flag;
while(!command.equals("E"))
{
flag=0;
commandArr = command.split("\\s");
if(commandArr[0].equals("I")) //Insertion
{
while(true)
{
if(commandArr.length==1&&flag!=2)
{
System.out.print((count)+"> ");
text = s.nextLine();
insertLine(text,count-1);
}
else if(commandArr.length==2&&flag!=2)
{
System.out.print((commandArr[1])+"> ");
count=Integer.parseInt(commandArr[1]);
text = s.nextLine();
insertLine(text,Integer.parseInt(commandArr[1])-1);
}
else
insertLine(text,count-1);
System.out.print((++count)+"> ");
command=s.nextLine();
commandArr = command.split("\\s");
if(commandArr[0].equals("I")||commandArr[0].equals("L")||commandArr[0].equals("D")||comm
andArr[0].equals("E"))
{
flag=1;
break;
}
else
{
flag=2;
text=command;
}
}
}
else if(commandArr[0].equals("L")) //Listing
{
printList();
}
else if(commandArr[0].equals("D")) //Deletion
{
if(commandArr.length==1)
{
deleteLine(count-1,count-1);
}
else if(commandArr.length==2)
{
deleteLine(Integer.parseInt(commandArr[1])-1,Integer.parseInt(commandArr[1])-1);
}
else if(commandArr.length==3)
{
deleteLine(Integer.parseInt(commandArr[1])-1,Integer.parseInt(commandArr[2])-1);
}
count=lines.size();
}
if(flag!=1)
{
System.out.print((count++)+"> ");
command = s.nextLine();
}
}
}
public static void insertLine(String text,int count)
{
if (count >= lines.size()) {
for(int i = lines.size(); i <= count; i++) {
lines.add(null);
}
}
lines.set(count,text);
}
public static void deleteLine(int start,int end)
{
for(int i=start;i<=end;i++)
lines.remove(i);
}
public static void printList()
{
for(int i=0;i "+lines.get(i));
}
}
Here is my output:
EDIT: textin.txt
1> The First Line
1>
2> And another line
3> I 3
3> The second line
4> One more line
5> L
1> null
2> null
3> The second line
4> One more line
5> D 2
3> L
1> null
2> The second line
3> One more line
4> E
How can I keep it from printing "null" after ">" and it just be blank. I need the output to look like
this:
1> The first line
2>
3> And another line
4> I 3
3> The second line
4> One more line
5> L
1> The first line
2>
3> The second line
4> One more line
5> And another line
5> D 2
4> L
1> The first line
2> The second line
3> One more line
4> And another line
5> E.
Core Java Programming Language (JSE) : Chapter XI - Console I/O and File I/OWebStackAcademy
Java.io.File Class in Java. The File class is Java's representation of a file or directory path name. ... A file system may implement restrictions to certain operations on the actual file-system object, such as reading, writing, and executing. These restrictions are collectively known as access permissions.
The program uses console I/O to simply read its "standard input (stdin)"—which might be the keyboard, a file dump, or the output of some other program—and print to its "standard output (stdout)"—which might be the display or printer or another program or a file.
JAVA Q2- Write a program that reads strings from the user and writes t.docxmichael1810
JAVA
Q2: Write a program that reads strings from the user and writes them to an output file called userStrings.txt. Stop processing when the user enters the string \"DONE\". Do not write the sentinel string (\"DONE\") to the output file. [15 points] Hint: For a complete example of file IO, please see the attached TestData program.
Sample Output:
A string.
Another string.
Yet more text...
DONE
Solution
Answer
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Scanner;
class WriteStringFile {
public static void main(String[] args) {
File file = new File(\"D:/userFile.txt\");
String data;
Scanner input = new Scanner(System.in);
data = input.readLine();
try (FileOutputStream fop = new FileOutputStream(file)) {
// if file doesn\'t exists, then create it
if (!file.exists()) {
file.createNewFile();
}
if (data != \"DONE\") {
// get the content in bytes
byte[] contentInBytes = content.getBytes();
fop.write(contentInBytes);
fop.flush();
fop.close();
} else {
System.out.println(\"User Enter the value Done.. So unable to write into file\");
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
.
Use Java to program the following.1. Create public java class name.pdff3apparelsonline
Use Java to program the following.
1. Create public java class named Benford.
2. It\'s main function should prompt for the name of a data file and then the function iterates
through the all of the elements in the data file and computes the frequency (count and
percentage) of the first number in each entry.
3. Note: Some of the data files have comments that you must filter out.
4. Also note: that blank lines or lines where the number begins or is 0 must also be filtered out.
5. Your output must be formatted as follows.
Solution
Hi Firend, Please find my code.
Please let me know in case of any issue.
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class CountFrequency {
public static void main(String[] args) throws FileNotFoundException {
Scanner sc = new Scanner(System.in);
// taking input file name
System.out.print(\"Enter input file name: \");
String fileName = sc.next();
// opening input file
Scanner inputFile = new Scanner(new File(fileName));
// declaring array to store count of first digit of each entery
int[] frequency = new int[10];
int totalCount = 0; // to maintain total count
int num;
// reading all lines
while(inputFile.hasNextLine()){
// reading current line
String line = inputFile.nextLine();
// if line is not empty
if(line == null || line.isEmpty() || line.trim() == \"\")
continue;
// taking first character of current line
char firstDigit = line.charAt(0);
// if first character is digit and not equal to 0
if(Character.isDigit(firstDigit) && firstDigit != \'0\'){
// converting first character of current line in integer
int d = firstDigit - \'0\';
frequency[d]++;
totalCount++;
}
}
System.out.println(\"Digit\\tCount\\tFrequency\");
for(int i=1; i<=9; i++){
System.out.println(i+\"\\t\"+frequency[i]+\"\\t\"+
((double)frequency[i]/(double)totalCount*100));
}
}
}
/*
Sample run:
##### Entry of input.txt:
453 43
//543
123
0
4ee
875
52
// Output
Enter input file name: input.txt
Digit Count Frequency
1 1 20.0
2 0 0.0
3 0 0.0
4 2 40.0
5 1 20.0
6 0 0.0
7 0 0.0
8 1 20.0
9 0 0.0
*/.
Change the code in Writer.java only to get it working. Must contain .pdfsecunderbadtirumalgi
Change the code in Writer.java only to get it working. Must contain methods: logReverse() ,
logMax(), logDuplicates(),
This lab is going to focus on File Output, which you will find is somewhat similar to console
output.
FileMain.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
public class FileMain {
public static void main(String[] args) throws IOException{
Scanner scnr = new Scanner(System.in);
System.out.print("Please enter the name of the file you would like to read: ");
String fileName = scnr.next();
Reader reader = new Reader();
ArrayList fileContents = reader.getFileContents(fileName);
System.out.println("Please enter a name for your new file: ");
String newFileName = scnr.next();
Writer fileOut = new Writer(newFileName);
fileOut.logReverse(fileContents);
fileOut.logMax(fileContents);
fileOut.logDuplicates(fileContents);
fileOut.closeWriter();
scnr.close();
}
}
Filetester.java
import java.io.IOException;
import java.util.ArrayList;
public class FileTester {
public static boolean testLogReverse(ArrayList contents) throws IOException {
Writer writer = new Writer("logReverseTest.txt");
writer.logReverse(contents);
writer.closeWriter();
ArrayList expected = new ArrayList();
expected.add("Reversed file contents: ");
expected.add("58");
expected.add("12");
expected.add("19");
expected.add("42");
expected.add("12");
expected.add("End of file.");
Reader testReader = new Reader();
ArrayList result = testReader.getFileContents("logReverseTest.txt");
if(expected.equals(result)) return true;
else return false;
}
public static boolean testLogMax(ArrayList contents) throws IOException {
Writer writer = new Writer("logMaxTest.txt");
writer.logMax(contents);
writer.closeWriter();
ArrayList expected = new ArrayList();
expected.add("The largest number in the file is: 58");
expected.add("End of file.");
Reader testReader = new Reader();
ArrayList result = testReader.getFileContents("logMaxTest.txt");
if(expected.equals(result)) return true;
else return false;
}
public static boolean testLogDuplicates(ArrayList contents) throws IOException {
Writer writer = new Writer("logDuplicatesTest.txt");
writer.logDuplicates(contents);
writer.closeWriter();
ArrayList expected = new ArrayList();
expected.add("Duplicates found: true");
expected.add("End of file.");
Reader testReader = new Reader();
ArrayList result = testReader.getFileContents("logDuplicatesTest.txt");
if(expected.equals(result)) return true;
else return false;
}
public static void main(String[] args) throws IOException {
Reader reader = new Reader();
ArrayList fileContents = reader.getFileContents("nums.txt");
System.out.println("logReverse test passed? " + testLogReverse(fileContents));
System.out.println("logMax test passed? " + testLogMax(fileContents));
System.out.println("logDuplicates test passed? " + testLogDuplicates(fileContents));
}
}
Reader.java
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Sca.
________ are characterized by small incisors and large premolars wit.pdffashiionbeutycare
________ are characterized by small incisors and large premolars with sharp crests.
a. Insectivores
b. Folivores
c. Faunivores
d. Frugivores
Solution
Folivores are characterized by small incisors and large premolar with sharp crest
Because they are basically herbivores taking cellulose rich leafs and plant stems so they need
proper chewing for digesting that.
Because of that usually they have large premolar and molar teeth and small or no incisors teeth..
why do Private offices have a high sensible heat ratioSolution.pdffashiionbeutycare
why do Private offices have a high sensible heat ratio?
Solution
the private offives where the high concentration is demanded the high sensible heat ratio is
because to maintain the humidity in summer
SHR=SENSIBLE HEAT/TOTAL HEAT so if sensible heat ratio will high then total heat will
low and so in office temperature is maintain.
Why is payback and IRR more frequently used than NPV when it comes t.pdffashiionbeutycare
Why is payback and IRR more frequently used than NPV when it comes to evaluating projects?
Solution
Payback is very simple to understand and cheap to implement and can be done very quickly to
give an idea.
IRR gives return in terms of percentage and management would like to see the returns because
then they are not biased with the size of the project. But NPV is biased with the size of the
project..
What general environmental condition is represented by this assemblag.pdffashiionbeutycare
What general environmental condition is represented by this assemblage - marine or nonmarine?
(b) Based on the fossil assemblage, describe the energy of each environment (e.g. turbulent wave
environment, calm offshore or lagoon) Shale: Sandstone: Limestone: (c) Which unit shows the
greatest biological diversity?
Solution
b. Shale - Shale is said to be deposited by the lower to outer shelf below wave base under low
energy conditions. Black shale containing fossil plants represents swamp environments.
Sandstone - Siliclastic carbonate sandstone contains deposition from shallow marine with high
energy near shore depositional environment . Pebbly sand stone also contains high energy
environments of the shore face. The cross bed sandstone which is deposited in the upper part also
is deposited by high energy environment like storm.
Limestone - limestone units of packstone - rudstone are high energy deposits whereas
wackestone - floatstone are deposits of low energy below wave base. Limestone composed of
float stone to rug stone deposition indicates its transition from low to high energy deposition.
Sandy lime stone contains deposits of high energy.
c. Limestone contains calcium carbonate and it gives the property to the rock for identification. It
has greater biodiversity compared to other types of rocks..
What are some of the basic features of Excavates Discuss the differe.pdffashiionbeutycare
What are some of the basic features of Excavates? Discuss the difference among major classes
of organisms found in this. For the toolbar press ALT +F10 (PC) or ALT + FN + F10 (Mac)
Solution
Excavates are a diverse group of unicellular Protists with Flagella.These protists are so named
because many have a deep, or excavated, oral groove. Unlike other protists, excavates have
atypical, greatly modified mitochondria. Many excavates are endosymbionts and live in anoxic
(without oxygen) environment. These excavates do not carry out aerobic respiration; they obtain
energy by the anaerobic pathway of glycolysis (presumably by fermentation).
The representatives protest clades are dipplomonads and parabasalids with the key characters of
two or more flagella; ventral oral (feeding) groove and Euglenoids and trypanosomes with the
key characters of some with plastids; crystalline red in flagella
Example: SEM of Trichomonas vaginalis, a parabasalid.
Currently, excavates include dipomonads, parabasalids, euglenoids, and trypanosomes. The
inclusion of these organisms inti single superfamily is somewhat controversial because their
relationship to one another are uncertain. Additional studies will be needed to determine if the
excavates as currently presented are monophyletic group.
Diplomonads are small mostly parasitic flagellates
Diplomonads are excavates that have one or two nuclei, no functional mitochondria, no Golgi
complex, and up to eight flagella. Example: Giardia is a parasitic diplomonad. Interestingly,
Giardia has two haploid nuclei, each of which contains a complete copy of giardia’s genome.
Giardia lacks functional mitochondria, although it contains certain genes that code for proteins
associated with mitochondria in other organism. Giardia also has reduced structures that
somewhat resembles mitochoindria.
Giardia intestinalis is a major cause of water-borne diarrhea through the world. Giardia is
eliminated as a resistant cyst in the feces of many vertebrate animals. These cysts are common
contaminant in untreated drinking water.
Parabasilids are anaerobic endosymbionts that live in animals
Parabasilids are anaerobic, flagellated excavates that often live in animals. Trichonymphs and
trichomonads are examples of parabasilids. Trichonymphs, which have hundreds of flagella, live
in the guts of termites and wood-eating cockroaches. The trichonymphs rely on endosymbiotic
bacteria to digest cellulose in the wood. The insects, trichonymphs, and bacteria all obtain their
nutrients from this source. This is excellent example of mutualism..
True or False Disulfides are essential for cone-snail venoms acti.pdffashiionbeutycare
True or False: Disulfides are essential for cone-snail venom\'s activity
Solution
Answer:
True:
Cone snails are marine metazoans mainly they are going to catch they prey by generating toxins
or venoms to inactivate their prey. These venom components are composed of disulfide bonds, in
which hypervariable disulfide-rich structural domains going to inactivate the protein folding in
the prey so that disulfides in venome proteins are essential for cone-snail venom\'s activity.
To what extent do GUI editors generally allow developers to modify H.pdffashiionbeutycare
To what extent do GUI editors generally allow developers to modify HTML code manually?
Solution
GUI HTML editors allow you to create Web pages. In most cases, you enter and edit text similar
to the way you would in a word-processing application. Images, tables, links,bookmarks and so
forth can be created easily because the application writes the HTML code automatically
GUI Web site management editors provide both Web page creation and site management
functionality. They allow teams of designers and developers to work in an integrated
environment to design, build and manage Web site and Internet applications. In addition to
creating the Web pages, team members can manage the entire Web site with this type of
application, both during and after development. Site management includes task automation and
workflow integration with other programs (such as Microsoft Office and Web applications) in a
production environment.
GUI HTML editors such as KompoZer, Sea Monkey Composer, Dreamweaver and
Expression Web present the following advantages for Web page authors:
• GUI HTML editor to develop Web pages can save you time.
• GUI editors place code into files for you, which enables you to create pages quickly by simply
clicking your mouse.
• Most GUI editors allow you to modify your code manually At the time of this writing, HTML5
was not supported by any open-source GUI or WYSIWYG HTML editors. Instead, an HTML5
template was required in KompoZer to produce the HTML5 declaration. Once the code is
complete, it must be validated and updated as needed.
The diagram shows a cell during the anaphase stage of mitosis. How wo.pdffashiionbeutycare
The diagram shows a cell during the anaphase stage of mitosis. How would this diagram be
different if it showed anaphase I of meiosis instead of anaphase of mitosis? Each chromosome
would still have two chromatids together. The chromosomes would look the same as in mitosis.
You would be able to see DNA in the chromosomes during meiosis. Homologous chromosomes
would be moving to the same end of the cell.
Solution
Answer is A
Each chromosome still have two chromatids together, which will further divide in anaphase II.
Thus giving 4 daughter cells..
Thank you for your helpful answer! Consider the following meth.pdffashiionbeutycare
Thank you for your helpful answer!
Consider the following method: bool hasDuplicates(int V[], int n) {for (int i=0; i
Solution
1)
So we can see that the total number of times the sequence of statements executes is:
N + N-1 + N-2 + ... + 3 + 2 + 1. the total is O(N2).
2)
Use count array to store frequency of each element in an array
traverse the entire array and find maximum element
create an array with size of maximum element and instantiate to zero
now traverse count array and see if it has value 2 for any index
if it has then array has duplicates
else no
O(n) complexityValue of iNumber of iterations of inner loop0N1N-12N-2......N-22N-11.
State whether the following statement is true or false The graph of t.pdffashiionbeutycare
State whether the following statement is true or false The graph of the reciprocal function f(x)
=1/x has a break and is composed of two distinct branches Choose the correct answer below
True False
Solution
The function : y = 1/x
x<0 : y = -1/x
x> 0 ; y = 1/x
The function is not defined at x= 0
so, there are two distinct functions
Option True.
Should Maria’s ethical responsibility to Linda lead her to keep thes.pdffashiionbeutycare
Should Maria’s ethical responsibility to Linda lead her to keep these concerns to herself and
allow the recommendation to stand?
Solution
Ethical responsibility mainly is used to follow the right path. Here, the actions of an individual
must benefit the whole society. So a person should speak up for the right thing. Every individual
is accountable for fulfilling their civic duty, even small business owners also have ethical
responsibilities to their employees, customers and society as a whole.
So if Maria feels there is something that would affect their customers, environment, business and
society as a whole, she should not keep her concerns to herself.
Revolution in Egypt With 83 million people, Egypt is the most populou.pdffashiionbeutycare
Revolution in Egypt With 83 million people, Egypt is the most populous Arab state. On the face
of it, c Egypt made significant economic progress during the 2000s. In 2004, the gov- emment of
Hosni Mubarak enacted a series of economic reforms that included calling for Mo and he step
that included reins of pow to dem trade liberalization, cuts in import tarifs, tax cuts, deregulation,
and changes in tion to dem on a s investment regulations that allowed for more foreign direct
investment in the voted on a Egyptian economy. As a consequence, economic growth, which had
been in way for the the 2 to 4 percent range during the early 2000s, accelerated to around 7 per-
Egyptians cent a year. Exports almost tripled, from $9 billion in 2004 to more than $25 bi Doest
lion by 2010. Foreign direct investment increased from $4 billion in 2004 to state with $11
billion in 2008, while unemployment fell from 11 percent to 8 percent. erate Isla By 2008, Egypt
seemed to be displaying many of the features of other country emerging economies. On Cairo\'s
outskirts, clusters of construction cranes Mohame could be seen where gleaming new offices
were being built for companies ment st such as Microsoft, Oracle, and Vodafone. Highways
were being con- was as structed, hypermarkets were opening their doors, and sales of private
cars on fore quadrupled between 2004 and 2008. Things seemed to be improving. ich But
appearances can be deceiving. Underneath the surface, Egypt had Foreig major economic and
political problems. Inflation, long a concern, remained fast. high at 12.8 percent. As the global
economic crisis took hold in 2008-2009, nomi Egypt saw many of its growth drivers slow. In
2008, tourism brought some subsi $11 billion into the country, accounting for 8.5 percent of
gross domestic not a product, but it fell sharply in 2009 and 2010. Remittances from Egyptian
budg expatriates working overseas, which amounted to $8.5 billion in 2008, de- cess clined
sharply as construction projects in the Gulf, where many of them the worked, were cut back or
shut down. Earnings from the Suez Canal, which tha stood at $5.2 billion in 2008, declined by 25
percent in 2009 as the volume ha of world shipping slumped in the wake of the global economic
slowdown. ba the rich and the poor. Some 44 percent of Egyptians are classified as poor or
extremely poor, the average wage is less than $100 a month. Some 2.6 million people are so
destitute that their entire income cannot cover their basic food needs ru his So
Solution
The Egyptian economy is dependent on the Egypt\'s political stability. Egypt is still governed by
a interim government.
Unemployment rate is high in Egypt. The current government should first make changes in the
economy to decrease unemployment rate. Many wealthy business men have left the country. The
interim government have to stabilise the economy to win back the confidence of egytian
entrepreneur class. This will positively affect the employment rate and will creat.
Question No. 1What updates have been brought by snmpv2 to SNMPv1 c.pdffashiionbeutycare
Question No. 1
What updates have been brought by snmpv2 to SNMPv1 communication architecture? [2 marks]
Question No. 2
How SNMPv3 enhances security compared to SNMPv2? [2 marks]
Question No. 3
Define RMON [1 mark]
What are the benefits of RMON ? [1 mark]
Question No. 4
As a network manager, you are responsible for the operation of a network. You notice heavy
traffic in a host that is on a TCP/IP network and want to find out the details:
What basic network monitoring tool(s) would you use? [1 mark]
What would you look for in your results? [1 mark]
Question No. 5
What is the difference between nslookup & dig? [1 marks]
Question No. 5
Install wireshark and capture IP packets on your Ethernet interface.
Put a screenshot of IP packets captured on your device. [1 marks]
Analyze their headers and contents. [2 marks] (1 mark bonus for
Solution
Answer 1.
SNMPv1 (Simple Network Management Protocol) v1 was designed as a short term solution to
allow management of TCP/IP - based internets. Although it was simple there were some major
issues in SNMPv1, viz Expressiveness of MIB definitions, performance and security issues.
Some key differences brought in SNMPv2 are:
Answer 2:
The newer version of SNMP, i.e. SNMPv3 was released to cover some of the security issues that
plagued SNMPv2. SNMPv3 framework augments the original SNMP and SNMPv2
specifications with additional security and administration capabilities. Security and remote
configuration capabilities were added in the newer version. The SNMPv3 architecture introduces
the User-based Security Model (USM) for message security and View-based Access Control
Model(VACM) for access control. The architecture supports the concurrent use of different
security, access control and message processing protocols. SNMPv2 also introduces the ability to
dynamically
configure the SNMP agent using SNMP SET commands against the MIB objects that represent
the agent\'s configuration. The dynamic configuration support enables addition, deletion and
modification of configuration entries locally or remotely. The latest architecture incorporates an
SNMP context engine ID to encode and decode SNMP contexts.
In short, SNMPv3 provides three layers of security. The highest level is with authentication and
privacy. The second or middle level is with authentication and no privacy and the bottom level is
without authentication and privacy.
Answer 3:
Remote Monitoring (RMON) is a standard specification that facilitates the monitoring ,
analyzing and troubleshooting of network operational activities through the use of remote
devices known as monitors or probes.
RMON provides the benefits of standarazation and improves efficiency by allowing you to
remain at one workstation and collect information from widely dispersed LAN segments or
VLANs. RMON also allows proactive management and reduces the traffic load.
Answer 4:
Microsoft network monitor and CapsaFree are a few of the basic tools one can use for in this
case. Main features of MNM i.
President Truman belleved that an increase in a na development, which.pdffashiionbeutycare
President Truman belleved that an increase in a na development, which typically includes the
exploitation of tion\'s ii means that a nation is moving toward economic . levels of consumption;
immigrant laborers O levels of consumption; natural resources O standard of living; immigrant
laborers Ostandard of living; natural resources
Solution
President Truman believed that an increase in nation\'s levels of consumption means that a nation
is moving towards economic development, which typically includes the exploitation of natural
resources..
Pretend you have been asked by the president of the united statesto .pdffashiionbeutycare
Pretend you have been asked by the president of the united statesto chair a special task force that
is to write a national policy statement on children\'s exposure to television. What
recommendations would you make concerning viewing hours and type of shows to be aired?
Relating television back to cognitive development, give two examples of how young children
might misunderstand plots of television shows or claims made on advertisements.
Solution
individuals suffering from social isolation can employ television to create what is termed a
parasocial or faux relationship with characters from their favorite television shows and movies as
a way of deflecting feelings of loneliness and social deprivation.Just as an individual would
spend time with a real person sharing opinions and thoughts, pseudo-relationships are formed
with TV characters by becoming personally invested in their lives as if they were a close friend
so that the individual can satiate the human desire to form meaningful relationships and establish
themselves in society. The pleasurable effects of television may be likened to an addictive
activity, producing \"momentary pleasure but long-term misery and regret.\"When a person plays
video games or watches TV, the basal ganglia portion of the brain becomes very active and
dopamine is released.Release of high amounts of dopamine reduces the amount of the
neurotransmitter available for control of movement, perception of pain and pleasure and
formation of feelings.Watching television starting at a young age can profoundly effect
children\'s development. These effects include obesity, language delays, and learning disabilities.
Physical inactivity while viewing TV reduces necessary exercise and leads to over-eating.
Language delays occurs when a child doesn\'t interact with others. Children learn language best
from live interaction with parents or other individuals. Resulting learning disabilities from over-
watching TV include ADHD, concentration problems and even reduction of IQ. Children who
watch too much television can thus have difficulties starting school because they aren\'t
interested in their teachers. Children should watch a maximum of 2 hours daily if any television.
At the same time, television can help young people discover where they fit into society, develop
closer relationships with peers and family, and teach them to understand complex social aspects
of communication.
Recommendations are:
Give a specific time,ie, like 2 hours/day for television watching and engage them in oter leisures
such as sports,arts,etc.The type of shows must be informative,such as about new
hobbies,improvements in science and technology and new discoveries or about great
people.Never go for anything like dating shows or something explicit children..
Please explain in detail. Why cant Salmonella be infected by lambd.pdffashiionbeutycare
Please explain in detail. Why can\'t Salmonella be infected by lambda phage? Why can\'t
salmonella be successfully transfected using lambda DNA?
Solution
Lambda phage is a bacteriophage or bacteria virus which is known to infect bacteria especially
Escherichia coli hence, sometimes also called as coliphage.This virus is used in recombinat DNA
technology for transferring special genes or you can say that as a vector. To infect a bacterium a
virus needs to:
1) interact first with the cell surface receptors which are different in different species thus,
making coliphage entry difficult inside the Salmonella species.
2) Multiplication of virus genome inside the bacteria is another factor for a virus to cause
infection in a bacterium. To multiply inside bacteria, phage join its nucleic acid with host\'s
nucleic acid, this stage of infection is called prophage. To attach its nucleic acid a phage must
recognise an attachment site called att site in host\'s genome which varies among different
genera. At this stage genetic exchange takes place hence, it is difficult too transfect Salmonella
with a coliphage.
However, Phage P22 can transfect Salmonella because the bacterium has specific att sites for
P22. Also, Transduction i.e. transfer of nucleic acid by a bacteriophage to bacteria was first
discovered in P22 infecting Salmonella. Salmonella species can be made competitive(
susceptible to genetic exchange by transfection) for coliphage by altering its genomic structure
using recombinant DNA tools..
Part A Tnsomy 21, or Down syndrome, occurs when there is anormal dplo.pdffashiionbeutycare
Part A Tnsomy 21, or Down syndrome, occurs when there is anormal dploid deomosomal
complement but one 21 Ahough ave higher (19 vrvna offspring would be expected to have Down
syndrome rboen parents have 0own syndrome? Given the that wen 48 chromosomes nou
chromosome 21) ly to survive oaydevekpront peroenlage ar O An the chadren would be expected
to have Down syndrome o None of surviving offsprang wous be expected to rave Down sydome
o one othe survivrg omsprng would be expected trav Downsyndrome O Two minds of surviving
preg wouldbe easected to have Down syndrome One hall the survning onspring would be
expected lo have Down syndoome Incorrect: Try Again: 2 attempts remaining a O Ask me
anything
Solution
one third of the surviving offspring will have Downs Syndrome
Since its inheritance is autosomal, so all children will not have Downzs syndrome. One which
will inherit both the copies of trisomy from both parents will have the syndrome.
Part 1 List the basic steps in securing an operating system. Assume.pdffashiionbeutycare
Part 1: List the basic steps in securing an operating system. Assume that the O.S. is being
installed for the first time on new hardware.
Part 2: Name and briefly describe two ways that college students could be recruited into illegal
espionage.
Part 3: Explain the function of the trusted boot function of the trusted platform module (TPM.)
Tell how that is related to the current controversy between Apple and the FBI concerning
encryption. What could the FBI do in the absence of a trusted boot function?
Part 4: Define single loss exposure and annualized risk of occurrence. Explain in your own
words what these have to do with computer security.
Part 5: Explain why it is important to monitor outbound traffic as well as inbound traffic in a
corporate network. Give an example
Solution
Part1:-
There are three things that can enhance operating system security across an enterprise network:
First, provisioning of the servers on the network should be done once in one place, involving the
roughly tens of separate configurations most organizations require. This image, or set of images,
can then be downloaded across the network, with the help of software that automates this process
and eliminates the pain of doing it manually for each server. Moreover, even if you had an
instruction sheet for these key configurations, you wouldn\'t want local administrators to access
these key configurations for each server, which is very dangerous. The best way to do it is once
and for all.
Once the network has been provisioned, administrators need to be able to verify policy
compliance, which defines user access rights and ensures that all configurations are correct. An
agent running on the network or remotely can monitor each server continuously, and such
monitoring wouldn\'t interfere with normal operations.
Second, account management needs to be centralized to control access to the network and to
ensure that users have appropriate access to enterprise resources. Policies, rules and intelligence
should be located in one place—not on each box—and should be pushed out from there to
provision user systems with correct IDs and permissions. An ID life cycle manager can be used
to automate this process and reduce the pain of doing this manually.
Third, the operating system should be configured so that it can be used to monitor activity on the
network easily and efficiently—revealing who is and isn\'t making connections, as well as
pointing out potential security events coming out of the operating system. Administrators can use
a central dashboard that monitors these events in real time and alerts them to serious problems
based on preset correlations and filtering. Just as important, this monitoring system should be set
up so that administrators aren\'t overwhelmed by routine events that don\'t jeopardize network
security.
Part2:-
Two ways that college students could be recruited into illegal espionage:
First, the students may be trend before they sending out to the foreign .
John is 35 years old and recently married with Eva. After they got m.pdffashiionbeutycare
John is 35 years old and recently married with Eva. After they got married, they are considering
to have their first child in 2 years and save for a deposit to buy an apartment. Which lifecycle
stage is John likely in?
Select one:
a. Wealth accumulation phase
b. Early family formation
c. Approaching retirement
d. Post retirement
e. Saving versus consumption phase
Solution
Answer :- Option e). Saving versus consumption phase.
Explanation :- John is likely in \"Saving versus consumption phase\" of lifecycle in the above
given question..
List three characteristics that an Intrusion Prevention System (IPS).pdffashiionbeutycare
List three characteristics that an Intrusion Prevention System (IPS) could use in identifying an
intruder to a network. Do you feel these systems are effective?
Solution
Intrusion Prevention System is a control device of security technology where it has the capacity
which it offers the security to all the system levels. That is, it provides the security from the
operating system to network data packets. When the data is transferred by the user, the IPS offers
some rules for the network traffic for alerting the user system or the network administrators by
giving alert that there will be a suspicious in the traffic. Then the administrator can take the
action on the suspicious and user can be attentive.
If there are any potential attacks then IPS makes attempts to stop it. IPS has the capacity that it
prevents the known intrusion signatures, and also some unknown attacks.
Yes, it is an effective system to avoid the attacks and protects the system in all levels by
providing the security..
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
Embracing GenAI - A Strategic ImperativePeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Write a Java program that opens the file, reads all the Grade from t.pdf
1. Write a Java program that opens the file, reads all the Grade from the file, and using a method
calculates and displays the following A) Displays the grades with their letter values (80 - B) B)
the sum of the Grades in the file C) the average of the Grades in the file
Solution
GradeRead.java
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class GradeRead {
public static void main(String[] args) throws FileNotFoundException {
Scanner scan1 = new Scanner(System.in);
System.out.print("Enter the file name: ");
String fileName = scan1.next();
File file = new File(fileName);
if(file.exists()){
Scanner scan = new Scanner(file);
calculateGradeDetail(scan);
}
else{
System.out.println("Input does not exist");
}
}
public static void calculateGradeDetail(Scanner scan){
int sum = 0;
int count = 0;
char gradeLetter = '0';
while(scan.hasNextInt()){
count++;
int n = scan.nextInt();
sum = sum + n;
if(n >=90 && n<=100){
gradeLetter = 'A';
2. }
else if(n >=80 && n<90){
gradeLetter = 'B';
}
else if(n >=70 && n<80){
gradeLetter = 'C';
}
else if(n >=60 && n<=70){
gradeLetter = 'D';
}
else {
gradeLetter = 'E';
}
System.out.println("Grade: "+gradeLetter+" - "+n);
}
System.out.println("The sum of the Grades in the file: "+sum);
double average = sum/(double)count;
System.out.println("the average of the Grades in the file: "+average);
System.out.println();
}
}
Output:
Enter the file name: D:grade.txt
Grade: D - 60
Grade: C - 70
Grade: B - 80
Grade: A - 90
Grade: A - 100
Grade: E - 40
Grade: E - 50
Grade: D - 60
The sum of the Grades in the file: 550
the average of the Grades in the file: 68.75
Grade.txt
60
70