Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.util.Scanner;
- public class Program {
- public static void main(String[] args) {
- /*
- * Kendred Thompson
- * 4th Period
- * CS 2
- * Curve a Quiz
- */
- //Variables
- File f;
- Scanner sc;
- double [] scores;
- int numScores;
- double pointsPossible;
- //Open the scores.txt file
- f = new File("scores.txt");
- try {
- sc = new Scanner(f);
- }
- catch(Exception e) {
- System.out.println("Error opening file.");
- System.out.println("Reading from Keyboard");
- sc = new Scanner(System.in);
- }
- //Find out how many scores are in the file
- numScores = sc.nextInt();
- //Find out the highest score possible
- pointsPossible = sc.nextDouble();
- //Read the scores into an array adding one point and displays them onto the screen
- scores = new double[numScores];
- int i = 0;
- while(i < numScores) {
- scores[i] = sc.nextDouble() + 1;
- System.out.println(scores[i]);
- i = i + 1;
- }
- sc.close(); //Close the file
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement