Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For JAVA ONLY please 7) A spreadsheet file can be stored as a comma separated fi

ID: 3766888 • Letter: F

Question

For JAVA ONLY please

7) A spreadsheet file can be stored as a comma separated file. For instance if a file called data.csv had the following in it:

name, quiz1, quiz2, quiz3, hw1, hw2, hw3, midterm, final

bill,8,9,10,50,45,43,88,93  

jill,9,9,10,50,48,40,90,91  

gill,6,5,7,38,22,40,70,73  

will,8,9,9,40,45,43,83,94  

totals,10,10,10,50,50,50,100,100

It would display in a program like Microsoft excel appropriately.

a) create a file called data.csv with this data on your hard drive.

b) read the file into a program calculating each students final percentage.

c) have the program write a new file with an extra column containing the final percentage for each student, a column heading for the first row, and the last row can end with 100 for its percentage.

If you could show the output for this I would be really grateful. Thank you !!

Explanation / Answer

package marks1;
import java.io.*; // includes buffered reader, writer, file reader, writer
import java.util.*; // includes scanner for user input


public class Marks1 {

    public static void main(String[] args) throws FileNotFoundException {
       /* FileInputStream fis = null; // declare input file pointer
        FileOutputStream fos = null;// declare output file pointer
      
        fis = new FileInputStream("E:/Files/data.csv"); // open the input files
        fos = new FileOutputStream("E:/Files/dataout.txt"); // output file
        */
        File ifp = new File("E:/Files/data.csv"); // input file pointer
        File ofp = new File("E:/Files/dataout.txt"); // output file pointer
      
        Scanner isc = new Scanner(ifp); // input scanner
        String name;
        int q1, q2, q3, h1=0, h2=0, h3=0, mt, f; // all 7+1 marks
        int qt; // quiz total
        int ht ; // home w tot
        int grTot; // grand total = qt + ht + mt + f
        float qAvg, hAvg, oAvg, avg; // quiz average, hw average, other Average, total average
        while(isc.hasNext())   {
            name = isc.next();
            q1 = isc.nextInt();
            q2 = isc.nextInt();
            q3 = isc.nextInt();
            qt = q1 + q2 + q3;
            qAvg = (float) ((qt / 30.00) * 100);
          
            ht = h1 + h2 + h3;
            hAvg = ( ht / 150 ) * 100;
          
          
                  
            h1 = isc.nextInt();
            h2 = isc.nextInt();
            h3 = isc.nextInt();
            mt = isc.nextInt();
            f = isc.nextInt();
            grTot = qt + ht + mt + f;
            oAvg = (mt + f ) / 2;
            avg = qAvg + hAvg + oAvg;
            System.out.println("Average " + avg);
        } // end while
      
      
    } // end main
  
} // end class

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote