![]() |
IOBit Software
|
|
|
||||||
| Programming Place to discuss programming including HTML, Java, C++, MySQL and others. |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Tomorrow I have an exam that requires that I know how to read inputs from a text file and display results. I was given an assignment, that If I can solve it, will help me with tomorrows exam. I don't expect anyone to help me write this. But whoever does, Thanks a lot. It's not suppose to take long at all to write. I just can't get it figured out. The assignment is as follows:
Problem 1 part a: Create the following text file ("Week9.txt"), which states exactly as written: 78 George 90 John 97 Alex 80 Thomas 75 James 87 Andrew 55 Frank 82 Anna 91 Maria 74 Anton 92 Carolina Problem 1 part b: Write a program that reads data from the file "Week9.txt" and displays: The Person's name, his/her score and comment: "good job", if the score is at least 80, "work harder", if 60<=score<80, "see your teacher", if score<60. The Person's name with highest score The Person's name with lowest score The average score Additional Details the programming language I'm using is Java, and I use JGrasp to run it. Also this is the code I came up with import java.io.*; import java.util.*; class ReadName { public static void main (String args []) throws IOException { String name; int score; Scanner inFile=new Scanner (new File ("Week9")); while (inFile.hasNext(); } inFile.close(); System.out.println(); } public static findGrade (int n) { String a; if (n>=80) a="good job" else if (n<80&&n>=60) a="work harder"; else a="see your teacher"; return a; } } |
| Sponsored links |
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Looking for easy & free word processing program | GrammawNewbie | Software | 6 | 01-10-07 15:32 |
| I Need A Easy To Use Newsletter Sending Program!!! | superstar | Software | 5 | 09-09-06 17:35 |
| easy way to make a dvd | jarfark | Software | 6 | 10-01-05 21:51 |
| How to make MyIE2 default browser / FlashGet not working | alanc | Software | 4 | 09-30-03 07:07 |