SlideShare a Scribd company logo
1 of 16
Download to read offline
SpreadsheetWriter.java
Can you please help me the JAVA program? Let's write a program that will produce a file that
can be opened by Excel or LibreOffice Calc. Go to Getting Started and look up the grading
weights used for this course. As an example, we'll use the following table, but you should use
the values you find in Getting Started. Write a class SSRow. Objects of this class should keep
track of String name, int score, int weight, String calc. SSRow also has a to String method that
returns this data in order, separated by commas. name + ", "+ score +", "+ weight +", "+ calc
Further design of the SSRow class is left to you. Add what you need, but don't get carried away.
Write a class SSWriter that has a main method. For each of the grading categories (Lab. Reading
Quizzes. Group Work. Midterm. Project. Final. Instructor Discretion). query the user for a score,
and create the following SSRow objects: "Lab", : 20. "=B1Times C1/100" "Reading
Quizzes". , 10, "=B2TimesC2/100" "Group Work". , 10, "=B3 Times C3/100" "Midterm".
. 20, "=B4 Times C4/100" "Project", . 15, "=B5 Times C5/100" "Final", . 20, "=B6 Times
C6/100" "Instructor Discretion". , 5, "=B7 Times C7/100" Open a file for output with a file
type of csv (say MyGrades.csv, for example). Write the to String value for each SSRow to the
file. Finally, write a row "average".=(D1+D2+D3+D4+D5+D6+D7) Open MyGrades.csv
with Excel or LibreOffice Calc.
Solution
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;
class SSRow{
String name;
int score;
int weight;
String cal;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
public String getCal() {
return cal;
}
public void setCal(String cal) {
this.cal = cal;
}
@Override
public String toString() {
return """ + name + "", "" + score + "", "" + weight + "", "" + cal + """;
}
}
public class SSWriter {
// Maintain a static map b/w workType and weights
private static final Map WORK_TYPE_TO_WEIGHT_MAP = new LinkedHashMap<>();
static {
WORK_TYPE_TO_WEIGHT_MAP.put("Lab", 20);
WORK_TYPE_TO_WEIGHT_MAP.put("Reading Quizzes", 10);
WORK_TYPE_TO_WEIGHT_MAP.put("Group Work", 10);
WORK_TYPE_TO_WEIGHT_MAP.put("Midterm", 20);
WORK_TYPE_TO_WEIGHT_MAP.put("Project", 15);
WORK_TYPE_TO_WEIGHT_MAP.put("Final", 20);
WORK_TYPE_TO_WEIGHT_MAP.put("Instructor Discretion", 5);
}
public static void main(String[] args) throws IOException {
Scanner scanner = new Scanner(System.in);
ArrayList list = new ArrayList<>(); // List to maintain the rows
int index = 1;
String avgString = "";
for(String workType : WORK_TYPE_TO_WEIGHT_MAP.keySet()){
System.out.println("Please enter the score for "+workType+": ");
int score = scanner.nextInt();
// Create a SSRow and set the parameters
SSRow ssRow = new SSRow();
ssRow.setName(workType);
ssRow.setScore(score);
ssRow.setWeight(WORK_TYPE_TO_WEIGHT_MAP.get(workType));
ssRow.setCal("=B"+index +"*C"+index+"/100");
list.add(ssRow);
if(index == 1) avgString +="=D"+index;
else avgString+= "+D"+index;
index++;
}
avgString = """+avgString+""";
PrintWriter printer = new PrintWriter(new FileWriter("/home/kumar/Desktop/MyGrades.csv"),
true);
for(SSRow ssRow : list){
printer.println(ssRow); // Write one row at a time
}
printer.println(""average", "+avgString); // Append average row
scanner.close(); // close the resources after using
printer.close();
System.out.println("Program execution completed.");
}
}
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;
class SSRow{
String name;
int score;
int weight;
String cal;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
public String getCal() {
return cal;
}
public void setCal(String cal) {
this.cal = cal;
}
@Override
public String toString() {
return """ + name + "", "" + score + "", "" + weight + "", "" + cal +
""";
}
}
public class SSWriter {
// Maintain a static map b/w workType and weights
private static final Map WORK_TYPE_TO_WEIGHT_MAP = new LinkedHashMap<>();
static {
WORK_TYPE_TO_WEIGHT_MAP.put("Lab", 20);
WORK_TYPE_TO_WEIGHT_MAP.put("Reading Quizzes", 10);
WORK_TYPE_TO_WEIGHT_MAP.put("Group Work", 10);
WORK_TYPE_TO_WEIGHT_MAP.put("Midterm", 20);
WORK_TYPE_TO_WEIGHT_MAP.put("Project", 15);
WORK_TYPE_TO_WEIGHT_MAP.put("Final", 20);
WORK_TYPE_TO_WEIGHT_MAP.put("Instructor Discretion", 5);
}
public static void main(String[] args) throws IOException {
Scanner scanner = new Scanner(System.in);
ArrayList list = new ArrayList<>(); // List to maintain the rows
int index = 1;
String avgString = "";
for(String workType : WORK_TYPE_TO_WEIGHT_MAP.keySet()){
System.out.println("Please enter the score for "+workType+": ");
int score = scanner.nextInt();
// Create a SSRow and set the parameters
SSRow ssRow = new SSRow();
ssRow.setName(workType);
ssRow.setScore(score);
ssRow.setWeight(WORK_TYPE_TO_WEIGHT_MAP.get(workType));
ssRow.setCal("=B"+index +"*C"+index+"/100");
list.add(ssRow);
if(index == 1) avgString +="=D"+index;
else avgString+= "+D"+index;
index++;
}
avgString = """+avgString+""";
PrintWriter printer = new PrintWriter(new
FileWriter("/home/kumar/Desktop/MyGrades.csv"), true);
for(SSRow ssRow : list){
printer.println(ssRow); // Write one row at a time
}
printer.println(""average", "+avgString); // Append average row
scanner.close(); // close the resources after using
printer.close();
System.out.println("Program execution completed.");
}
}
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;
class SSRow{
String name;
int score;
int weight;
String cal;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
public String getCal() {
return cal;
}
public void setCal(String cal) {
this.cal = cal;
}
@Override
public String toString() {
return """ + name + "", "" + score + "", "" + weight + "", "" + cal + """;
}
}
public class SSWriter {
// Maintain a static map b/w workType and weights
private static final Map WORK_TYPE_TO_WEIGHT_MAP = new LinkedHashMap<>();
static {
WORK_TYPE_TO_WEIGHT_MAP.put("Lab", 20);
WORK_TYPE_TO_WEIGHT_MAP.put("Reading Quizzes", 10);
WORK_TYPE_TO_WEIGHT_MAP.put("Group Work", 10);
WORK_TYPE_TO_WEIGHT_MAP.put("Midterm", 20);
WORK_TYPE_TO_WEIGHT_MAP.put("Project", 15);
WORK_TYPE_TO_WEIGHT_MAP.put("Final", 20);
WORK_TYPE_TO_WEIGHT_MAP.put("Instructor Discretion", 5);
}
public static void main(String[] args) throws IOException {
Scanner scanner = new Scanner(System.in);
ArrayList list = new ArrayList<>(); // List to maintain the rows
int index = 1;
String avgString = "";
for(String workType : WORK_TYPE_TO_WEIGHT_MAP.keySet()){
System.out.println("Please enter the score for "+workType+": ");
int score = scanner.nextInt();
// Create a SSRow and set the parameters
SSRow ssRow = new SSRow();
ssRow.setName(workType);
ssRow.setScore(score);
ssRow.setWeight(WORK_TYPE_TO_WEIGHT_MAP.get(workType));
ssRow.setCal("=B"+index +"*C"+index+"/100");
list.add(ssRow);
if(index == 1) avgString +="=D"+index;
else avgString+= "+D"+index;
index++;
}
avgString = """+avgString+""";
PrintWriter printer = new PrintWriter(new FileWriter("/home/kumar/Desktop/MyGrades.csv"),
true);
for(SSRow ssRow : list){
printer.println(ssRow); // Write one row at a time
}
printer.println(""average", "+avgString); // Append average row
scanner.close(); // close the resources after using
printer.close();
System.out.println("Program execution completed.");
}
}
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;
class SSRow{
String name;
int score;
int weight;
String cal;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
public String getCal() {
return cal;
}
public void setCal(String cal) {
this.cal = cal;
}
@Override
public String toString() {
return """ + name + "", "" + score + "", "" + weight + "", "" + cal + """;
}
}
public class SSWriter {
// Maintain a static map b/w workType and weights
private static final Map WORK_TYPE_TO_WEIGHT_MAP = new LinkedHashMap<>();
static {
WORK_TYPE_TO_WEIGHT_MAP.put("Lab", 20);
WORK_TYPE_TO_WEIGHT_MAP.put("Reading Quizzes", 10);
WORK_TYPE_TO_WEIGHT_MAP.put("Group Work", 10);
WORK_TYPE_TO_WEIGHT_MAP.put("Midterm", 20);
WORK_TYPE_TO_WEIGHT_MAP.put("Project", 15);
WORK_TYPE_TO_WEIGHT_MAP.put("Final", 20);
WORK_TYPE_TO_WEIGHT_MAP.put("Instructor Discretion", 5);
}
public static void main(String[] args) throws IOException {
Scanner scanner = new Scanner(System.in);
ArrayList list = new ArrayList<>(); // List to maintain the rows
int index = 1;
String avgString = "";
for(String workType : WORK_TYPE_TO_WEIGHT_MAP.keySet()){
System.out.println("Please enter the score for "+workType+": ");
int score = scanner.nextInt();
// Create a SSRow and set the parameters
SSRow ssRow = new SSRow();
ssRow.setName(workType);
ssRow.setScore(score);
ssRow.setWeight(WORK_TYPE_TO_WEIGHT_MAP.get(workType));
ssRow.setCal("=B"+index +"*C"+index+"/100");
list.add(ssRow);
if(index == 1) avgString +="=D"+index;
else avgString+= "+D"+index;
index++;
}
avgString = """+avgString+""";
PrintWriter printer = new PrintWriter(new FileWriter("/home/kumar/Desktop/MyGrades.csv"),
true);
for(SSRow ssRow : list){
printer.println(ssRow); // Write one row at a time
}
printer.println(""average", "+avgString); // Append average row
scanner.close(); // close the resources after using
printer.close();
System.out.println("Program execution completed.");
}
}
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;
class SSRow{
String name;
int score;
int weight;
String cal;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
public String getCal() {
return cal;
}
public void setCal(String cal) {
this.cal = cal;
}
@Override
public String toString() {
return """ + name + "", "" + score + "", "" + weight + "", "" + cal +
""";
}
}
public class SSWriter {
// Maintain a static map b/w workType and weights
private static final Map WORK_TYPE_TO_WEIGHT_MAP = new LinkedHashMap<>();
static {
WORK_TYPE_TO_WEIGHT_MAP.put("Lab", 20);
WORK_TYPE_TO_WEIGHT_MAP.put("Reading Quizzes", 10);
WORK_TYPE_TO_WEIGHT_MAP.put("Group Work", 10);
WORK_TYPE_TO_WEIGHT_MAP.put("Midterm", 20);
WORK_TYPE_TO_WEIGHT_MAP.put("Project", 15);
WORK_TYPE_TO_WEIGHT_MAP.put("Final", 20);
WORK_TYPE_TO_WEIGHT_MAP.put("Instructor Discretion", 5);
}
public static void main(String[] args) throws IOException {
Scanner scanner = new Scanner(System.in);
ArrayList list = new ArrayList<>(); // List to maintain the rows
int index = 1;
String avgString = "";
for(String workType : WORK_TYPE_TO_WEIGHT_MAP.keySet()){
System.out.println("Please enter the score for "+workType+": ");
int score = scanner.nextInt();
// Create a SSRow and set the parameters
SSRow ssRow = new SSRow();
ssRow.setName(workType);
ssRow.setScore(score);
ssRow.setWeight(WORK_TYPE_TO_WEIGHT_MAP.get(workType));
ssRow.setCal("=B"+index +"*C"+index+"/100");
list.add(ssRow);
if(index == 1) avgString +="=D"+index;
else avgString+= "+D"+index;
index++;
}
avgString = """+avgString+""";
PrintWriter printer = new PrintWriter(new
FileWriter("/home/kumar/Desktop/MyGrades.csv"), true);
for(SSRow ssRow : list){
printer.println(ssRow); // Write one row at a time
}
printer.println(""average", "+avgString); // Append average row
scanner.close(); // close the resources after using
printer.close();
System.out.println("Program execution completed.");
}
}
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;
class SSRow{
String name;
int score;
int weight;
String cal;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
public String getCal() {
return cal;
}
public void setCal(String cal) {
this.cal = cal;
}
@Override
public String toString() {
return """ + name + "", "" + score + "", "" + weight + "", "" + cal + """;
}
}
public class SSWriter {
// Maintain a static map b/w workType and weights
private static final Map WORK_TYPE_TO_WEIGHT_MAP = new LinkedHashMap<>();
static {
WORK_TYPE_TO_WEIGHT_MAP.put("Lab", 20);
WORK_TYPE_TO_WEIGHT_MAP.put("Reading Quizzes", 10);
WORK_TYPE_TO_WEIGHT_MAP.put("Group Work", 10);
WORK_TYPE_TO_WEIGHT_MAP.put("Midterm", 20);
WORK_TYPE_TO_WEIGHT_MAP.put("Project", 15);
WORK_TYPE_TO_WEIGHT_MAP.put("Final", 20);
WORK_TYPE_TO_WEIGHT_MAP.put("Instructor Discretion", 5);
}
public static void main(String[] args) throws IOException {
Scanner scanner = new Scanner(System.in);
ArrayList list = new ArrayList<>(); // List to maintain the rows
int index = 1;
String avgString = "";
for(String workType : WORK_TYPE_TO_WEIGHT_MAP.keySet()){
System.out.println("Please enter the score for "+workType+": ");
int score = scanner.nextInt();
// Create a SSRow and set the parameters
SSRow ssRow = new SSRow();
ssRow.setName(workType);
ssRow.setScore(score);
ssRow.setWeight(WORK_TYPE_TO_WEIGHT_MAP.get(workType));
ssRow.setCal("=B"+index +"*C"+index+"/100");
list.add(ssRow);
if(index == 1) avgString +="=D"+index;
else avgString+= "+D"+index;
index++;
}
avgString = """+avgString+""";
PrintWriter printer = new PrintWriter(new FileWriter("/home/kumar/Desktop/MyGrades.csv"),
true);
for(SSRow ssRow : list){
printer.println(ssRow); // Write one row at a time
}
printer.println(""average", "+avgString); // Append average row
scanner.close(); // close the resources after using
printer.close();
System.out.println("Program execution completed.");
}
}

More Related Content

Similar to SpreadsheetWriter.javaCan you please help me the JAVA program Let.pdf

React table tutorial project setup, use table, and usefilter
React table tutorial project setup, use table, and usefilterReact table tutorial project setup, use table, and usefilter
React table tutorial project setup, use table, and usefilterKaty Slemon
 
How do I fix this error - Exception in thread -main- java-lang-NullPoi.pdf
How do I fix this error - Exception in thread -main- java-lang-NullPoi.pdfHow do I fix this error - Exception in thread -main- java-lang-NullPoi.pdf
How do I fix this error - Exception in thread -main- java-lang-NullPoi.pdfpnaran46
 
Java tutorial for Beginners and Entry Level
Java tutorial for Beginners and Entry LevelJava tutorial for Beginners and Entry Level
Java tutorial for Beginners and Entry LevelRamrao Desai
 
Java Generics
Java GenericsJava Generics
Java Genericsjeslie
 
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdfCreat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdfaromanets
 
Rewriting Java In Scala
Rewriting Java In ScalaRewriting Java In Scala
Rewriting Java In ScalaSkills Matter
 
Circle.javaimport java.text.DecimalFormat;public class Circle {.pdf
Circle.javaimport java.text.DecimalFormat;public class Circle {.pdfCircle.javaimport java.text.DecimalFormat;public class Circle {.pdf
Circle.javaimport java.text.DecimalFormat;public class Circle {.pdfANJALIENTERPRISES1
 
How to fix this error- Exception in thread -main- q- Exit java-lang-.pdf
How to fix this error-   Exception in thread -main- q- Exit java-lang-.pdfHow to fix this error-   Exception in thread -main- q- Exit java-lang-.pdf
How to fix this error- Exception in thread -main- q- Exit java-lang-.pdfaarokyaaqua
 
ImplementDijkstra’s algorithm using the graph class you implemente.pdf
ImplementDijkstra’s algorithm using the graph class you implemente.pdfImplementDijkstra’s algorithm using the graph class you implemente.pdf
ImplementDijkstra’s algorithm using the graph class you implemente.pdfgopalk44
 
Jeop game-final-review
Jeop game-final-reviewJeop game-final-review
Jeop game-final-reviewStephanie Weirich
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionDmitry Sheiko
 
define a class name Employee whose objects are records for employee..pdf
define a class name Employee whose objects are records for employee..pdfdefine a class name Employee whose objects are records for employee..pdf
define a class name Employee whose objects are records for employee..pdffashioncollection2
 
Hello. Im currently working on the last section to my assignment a.pdf
Hello. Im currently working on the last section to my assignment a.pdfHello. Im currently working on the last section to my assignment a.pdf
Hello. Im currently working on the last section to my assignment a.pdfirshadkumar3
 
05 Geographic scripting in uDig - halfway between user and developer
05 Geographic scripting in uDig - halfway between user and developer05 Geographic scripting in uDig - halfway between user and developer
05 Geographic scripting in uDig - halfway between user and developerAndrea Antonello
 
Test beautycleanness
Test beautycleannessTest beautycleanness
Test beautycleannessbergel
 

Similar to SpreadsheetWriter.javaCan you please help me the JAVA program Let.pdf (20)

React table tutorial project setup, use table, and usefilter
React table tutorial project setup, use table, and usefilterReact table tutorial project setup, use table, and usefilter
React table tutorial project setup, use table, and usefilter
 
How do I fix this error - Exception in thread -main- java-lang-NullPoi.pdf
How do I fix this error - Exception in thread -main- java-lang-NullPoi.pdfHow do I fix this error - Exception in thread -main- java-lang-NullPoi.pdf
How do I fix this error - Exception in thread -main- java-lang-NullPoi.pdf
 
Workshop Scala
Workshop ScalaWorkshop Scala
Workshop Scala
 
Java tutorial for Beginners and Entry Level
Java tutorial for Beginners and Entry LevelJava tutorial for Beginners and Entry Level
Java tutorial for Beginners and Entry Level
 
Java Generics
Java GenericsJava Generics
Java Generics
 
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdfCreat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
 
Rewriting Java In Scala
Rewriting Java In ScalaRewriting Java In Scala
Rewriting Java In Scala
 
Circle.javaimport java.text.DecimalFormat;public class Circle {.pdf
Circle.javaimport java.text.DecimalFormat;public class Circle {.pdfCircle.javaimport java.text.DecimalFormat;public class Circle {.pdf
Circle.javaimport java.text.DecimalFormat;public class Circle {.pdf
 
How to fix this error- Exception in thread -main- q- Exit java-lang-.pdf
How to fix this error-   Exception in thread -main- q- Exit java-lang-.pdfHow to fix this error-   Exception in thread -main- q- Exit java-lang-.pdf
How to fix this error- Exception in thread -main- q- Exit java-lang-.pdf
 
WDD_lec_06.ppt
WDD_lec_06.pptWDD_lec_06.ppt
WDD_lec_06.ppt
 
ImplementDijkstra’s algorithm using the graph class you implemente.pdf
ImplementDijkstra’s algorithm using the graph class you implemente.pdfImplementDijkstra’s algorithm using the graph class you implemente.pdf
ImplementDijkstra’s algorithm using the graph class you implemente.pdf
 
Jeop game-final-review
Jeop game-final-reviewJeop game-final-review
Jeop game-final-review
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
ES6 Overview
ES6 OverviewES6 Overview
ES6 Overview
 
Lec2
Lec2Lec2
Lec2
 
define a class name Employee whose objects are records for employee..pdf
define a class name Employee whose objects are records for employee..pdfdefine a class name Employee whose objects are records for employee..pdf
define a class name Employee whose objects are records for employee..pdf
 
Hello. Im currently working on the last section to my assignment a.pdf
Hello. Im currently working on the last section to my assignment a.pdfHello. Im currently working on the last section to my assignment a.pdf
Hello. Im currently working on the last section to my assignment a.pdf
 
05 Geographic scripting in uDig - halfway between user and developer
05 Geographic scripting in uDig - halfway between user and developer05 Geographic scripting in uDig - halfway between user and developer
05 Geographic scripting in uDig - halfway between user and developer
 
Internal workshop es6_2015
Internal workshop es6_2015Internal workshop es6_2015
Internal workshop es6_2015
 
Test beautycleanness
Test beautycleannessTest beautycleanness
Test beautycleanness
 

More from ezonesolutions

hi need help with this question, ignore the circles (f) Indicate .pdf
hi need help with this question, ignore the circles (f) Indicate .pdfhi need help with this question, ignore the circles (f) Indicate .pdf
hi need help with this question, ignore the circles (f) Indicate .pdfezonesolutions
 
Explain TWO examples of fungal interactions with other speciesSo.pdf
Explain TWO examples of fungal interactions with other speciesSo.pdfExplain TWO examples of fungal interactions with other speciesSo.pdf
Explain TWO examples of fungal interactions with other speciesSo.pdfezonesolutions
 
DNA replicationTranscriptionTranslationPurposeWhere it occur.pdf
DNA replicationTranscriptionTranslationPurposeWhere it occur.pdfDNA replicationTranscriptionTranslationPurposeWhere it occur.pdf
DNA replicationTranscriptionTranslationPurposeWhere it occur.pdfezonesolutions
 
Does Microsoft directly disclose LinkedIn revenue for 2016 Explain .pdf
Does Microsoft directly disclose LinkedIn revenue for 2016 Explain .pdfDoes Microsoft directly disclose LinkedIn revenue for 2016 Explain .pdf
Does Microsoft directly disclose LinkedIn revenue for 2016 Explain .pdfezonesolutions
 
continuous, analytic, differentiableWhat is the relationship betwe.pdf
continuous, analytic, differentiableWhat is the relationship betwe.pdfcontinuous, analytic, differentiableWhat is the relationship betwe.pdf
continuous, analytic, differentiableWhat is the relationship betwe.pdfezonesolutions
 
Define the types of ultrasound pressure wavesSolutionUltrasoun.pdf
Define the types of ultrasound pressure wavesSolutionUltrasoun.pdfDefine the types of ultrasound pressure wavesSolutionUltrasoun.pdf
Define the types of ultrasound pressure wavesSolutionUltrasoun.pdfezonesolutions
 
Consider the current national debate about the revelation that top g.pdf
Consider the current national debate about the revelation that top g.pdfConsider the current national debate about the revelation that top g.pdf
Consider the current national debate about the revelation that top g.pdfezonesolutions
 
Case Study UrolithiasisCase PresentationDaniel, a thirty-two ye.pdf
Case Study UrolithiasisCase PresentationDaniel, a thirty-two ye.pdfCase Study UrolithiasisCase PresentationDaniel, a thirty-two ye.pdf
Case Study UrolithiasisCase PresentationDaniel, a thirty-two ye.pdfezonesolutions
 
A recombinant DNA was constructed by inserting the DNA of interest i.pdf
A recombinant DNA was constructed by inserting the DNA of interest i.pdfA recombinant DNA was constructed by inserting the DNA of interest i.pdf
A recombinant DNA was constructed by inserting the DNA of interest i.pdfezonesolutions
 
A conductor of length l lies along the x axis with current I in the +.pdf
A conductor of length l lies along the x axis with current I in the +.pdfA conductor of length l lies along the x axis with current I in the +.pdf
A conductor of length l lies along the x axis with current I in the +.pdfezonesolutions
 
What are the main motives for establishing an international joint ve.pdf
What are the main motives for establishing an international joint ve.pdfWhat are the main motives for establishing an international joint ve.pdf
What are the main motives for establishing an international joint ve.pdfezonesolutions
 
9 & 10 9. The study of behavioral finance has best helped explain .pdf
9 & 10 9. The study of behavioral finance has best helped explain .pdf9 & 10 9. The study of behavioral finance has best helped explain .pdf
9 & 10 9. The study of behavioral finance has best helped explain .pdfezonesolutions
 
Will Chinas economic success continue into the foreseeable future.pdf
Will Chinas economic success continue into the foreseeable future.pdfWill Chinas economic success continue into the foreseeable future.pdf
Will Chinas economic success continue into the foreseeable future.pdfezonesolutions
 
Which of the following ions would exhibit the greatest conductivity.pdf
Which of the following ions would exhibit the greatest conductivity.pdfWhich of the following ions would exhibit the greatest conductivity.pdf
Which of the following ions would exhibit the greatest conductivity.pdfezonesolutions
 
Which fault-tolerant-like system can back up media in much the same .pdf
Which fault-tolerant-like system can back up media in much the same .pdfWhich fault-tolerant-like system can back up media in much the same .pdf
Which fault-tolerant-like system can back up media in much the same .pdfezonesolutions
 
When may a federal court hear a caseSolutionFederal Court wil.pdf
When may a federal court hear a caseSolutionFederal Court wil.pdfWhen may a federal court hear a caseSolutionFederal Court wil.pdf
When may a federal court hear a caseSolutionFederal Court wil.pdfezonesolutions
 
4) Production in the country of StockVille can be characterized by th.pdf
4) Production in the country of StockVille can be characterized by th.pdf4) Production in the country of StockVille can be characterized by th.pdf
4) Production in the country of StockVille can be characterized by th.pdfezonesolutions
 
What is the pre-order traversal sequence for the above treeSolut.pdf
What is the pre-order traversal sequence for the above treeSolut.pdfWhat is the pre-order traversal sequence for the above treeSolut.pdf
What is the pre-order traversal sequence for the above treeSolut.pdfezonesolutions
 
Show that the class P, viewed as a set of languages is closed under c.pdf
Show that the class P, viewed as a set of languages is closed under c.pdfShow that the class P, viewed as a set of languages is closed under c.pdf
Show that the class P, viewed as a set of languages is closed under c.pdfezonesolutions
 
Related to Making the Connection] In the court case over whether any.pdf
Related to Making the Connection] In the court case over whether any.pdfRelated to Making the Connection] In the court case over whether any.pdf
Related to Making the Connection] In the court case over whether any.pdfezonesolutions
 

More from ezonesolutions (20)

hi need help with this question, ignore the circles (f) Indicate .pdf
hi need help with this question, ignore the circles (f) Indicate .pdfhi need help with this question, ignore the circles (f) Indicate .pdf
hi need help with this question, ignore the circles (f) Indicate .pdf
 
Explain TWO examples of fungal interactions with other speciesSo.pdf
Explain TWO examples of fungal interactions with other speciesSo.pdfExplain TWO examples of fungal interactions with other speciesSo.pdf
Explain TWO examples of fungal interactions with other speciesSo.pdf
 
DNA replicationTranscriptionTranslationPurposeWhere it occur.pdf
DNA replicationTranscriptionTranslationPurposeWhere it occur.pdfDNA replicationTranscriptionTranslationPurposeWhere it occur.pdf
DNA replicationTranscriptionTranslationPurposeWhere it occur.pdf
 
Does Microsoft directly disclose LinkedIn revenue for 2016 Explain .pdf
Does Microsoft directly disclose LinkedIn revenue for 2016 Explain .pdfDoes Microsoft directly disclose LinkedIn revenue for 2016 Explain .pdf
Does Microsoft directly disclose LinkedIn revenue for 2016 Explain .pdf
 
continuous, analytic, differentiableWhat is the relationship betwe.pdf
continuous, analytic, differentiableWhat is the relationship betwe.pdfcontinuous, analytic, differentiableWhat is the relationship betwe.pdf
continuous, analytic, differentiableWhat is the relationship betwe.pdf
 
Define the types of ultrasound pressure wavesSolutionUltrasoun.pdf
Define the types of ultrasound pressure wavesSolutionUltrasoun.pdfDefine the types of ultrasound pressure wavesSolutionUltrasoun.pdf
Define the types of ultrasound pressure wavesSolutionUltrasoun.pdf
 
Consider the current national debate about the revelation that top g.pdf
Consider the current national debate about the revelation that top g.pdfConsider the current national debate about the revelation that top g.pdf
Consider the current national debate about the revelation that top g.pdf
 
Case Study UrolithiasisCase PresentationDaniel, a thirty-two ye.pdf
Case Study UrolithiasisCase PresentationDaniel, a thirty-two ye.pdfCase Study UrolithiasisCase PresentationDaniel, a thirty-two ye.pdf
Case Study UrolithiasisCase PresentationDaniel, a thirty-two ye.pdf
 
A recombinant DNA was constructed by inserting the DNA of interest i.pdf
A recombinant DNA was constructed by inserting the DNA of interest i.pdfA recombinant DNA was constructed by inserting the DNA of interest i.pdf
A recombinant DNA was constructed by inserting the DNA of interest i.pdf
 
A conductor of length l lies along the x axis with current I in the +.pdf
A conductor of length l lies along the x axis with current I in the +.pdfA conductor of length l lies along the x axis with current I in the +.pdf
A conductor of length l lies along the x axis with current I in the +.pdf
 
What are the main motives for establishing an international joint ve.pdf
What are the main motives for establishing an international joint ve.pdfWhat are the main motives for establishing an international joint ve.pdf
What are the main motives for establishing an international joint ve.pdf
 
9 & 10 9. The study of behavioral finance has best helped explain .pdf
9 & 10 9. The study of behavioral finance has best helped explain .pdf9 & 10 9. The study of behavioral finance has best helped explain .pdf
9 & 10 9. The study of behavioral finance has best helped explain .pdf
 
Will Chinas economic success continue into the foreseeable future.pdf
Will Chinas economic success continue into the foreseeable future.pdfWill Chinas economic success continue into the foreseeable future.pdf
Will Chinas economic success continue into the foreseeable future.pdf
 
Which of the following ions would exhibit the greatest conductivity.pdf
Which of the following ions would exhibit the greatest conductivity.pdfWhich of the following ions would exhibit the greatest conductivity.pdf
Which of the following ions would exhibit the greatest conductivity.pdf
 
Which fault-tolerant-like system can back up media in much the same .pdf
Which fault-tolerant-like system can back up media in much the same .pdfWhich fault-tolerant-like system can back up media in much the same .pdf
Which fault-tolerant-like system can back up media in much the same .pdf
 
When may a federal court hear a caseSolutionFederal Court wil.pdf
When may a federal court hear a caseSolutionFederal Court wil.pdfWhen may a federal court hear a caseSolutionFederal Court wil.pdf
When may a federal court hear a caseSolutionFederal Court wil.pdf
 
4) Production in the country of StockVille can be characterized by th.pdf
4) Production in the country of StockVille can be characterized by th.pdf4) Production in the country of StockVille can be characterized by th.pdf
4) Production in the country of StockVille can be characterized by th.pdf
 
What is the pre-order traversal sequence for the above treeSolut.pdf
What is the pre-order traversal sequence for the above treeSolut.pdfWhat is the pre-order traversal sequence for the above treeSolut.pdf
What is the pre-order traversal sequence for the above treeSolut.pdf
 
Show that the class P, viewed as a set of languages is closed under c.pdf
Show that the class P, viewed as a set of languages is closed under c.pdfShow that the class P, viewed as a set of languages is closed under c.pdf
Show that the class P, viewed as a set of languages is closed under c.pdf
 
Related to Making the Connection] In the court case over whether any.pdf
Related to Making the Connection] In the court case over whether any.pdfRelated to Making the Connection] In the court case over whether any.pdf
Related to Making the Connection] In the court case over whether any.pdf
 

Recently uploaded

Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 đź’ž Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 đź’ž Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 đź’ž Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 đź’ž Full Nigh...Pooja Nehwal
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 

Recently uploaded (20)

Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 đź’ž Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 đź’ž Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 đź’ž Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 đź’ž Full Nigh...
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 

SpreadsheetWriter.javaCan you please help me the JAVA program Let.pdf

  • 1. SpreadsheetWriter.java Can you please help me the JAVA program? Let's write a program that will produce a file that can be opened by Excel or LibreOffice Calc. Go to Getting Started and look up the grading weights used for this course. As an example, we'll use the following table, but you should use the values you find in Getting Started. Write a class SSRow. Objects of this class should keep track of String name, int score, int weight, String calc. SSRow also has a to String method that returns this data in order, separated by commas. name + ", "+ score +", "+ weight +", "+ calc Further design of the SSRow class is left to you. Add what you need, but don't get carried away. Write a class SSWriter that has a main method. For each of the grading categories (Lab. Reading Quizzes. Group Work. Midterm. Project. Final. Instructor Discretion). query the user for a score, and create the following SSRow objects: "Lab", : 20. "=B1Times C1/100" "Reading Quizzes". , 10, "=B2TimesC2/100" "Group Work". , 10, "=B3 Times C3/100" "Midterm". . 20, "=B4 Times C4/100" "Project", . 15, "=B5 Times C5/100" "Final", . 20, "=B6 Times C6/100" "Instructor Discretion". , 5, "=B7 Times C7/100" Open a file for output with a file type of csv (say MyGrades.csv, for example). Write the to String value for each SSRow to the file. Finally, write a row "average".=(D1+D2+D3+D4+D5+D6+D7) Open MyGrades.csv with Excel or LibreOffice Calc. Solution import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.Map; import java.util.Scanner; class SSRow{ String name; int score; int weight; String cal; public String getName() { return name; }
  • 2. public void setName(String name) { this.name = name; } public int getScore() { return score; } public void setScore(int score) { this.score = score; } public int getWeight() { return weight; } public void setWeight(int weight) { this.weight = weight; } public String getCal() { return cal; } public void setCal(String cal) { this.cal = cal; } @Override public String toString() { return """ + name + "", "" + score + "", "" + weight + "", "" + cal + """; } } public class SSWriter { // Maintain a static map b/w workType and weights private static final Map WORK_TYPE_TO_WEIGHT_MAP = new LinkedHashMap<>(); static { WORK_TYPE_TO_WEIGHT_MAP.put("Lab", 20); WORK_TYPE_TO_WEIGHT_MAP.put("Reading Quizzes", 10); WORK_TYPE_TO_WEIGHT_MAP.put("Group Work", 10); WORK_TYPE_TO_WEIGHT_MAP.put("Midterm", 20); WORK_TYPE_TO_WEIGHT_MAP.put("Project", 15); WORK_TYPE_TO_WEIGHT_MAP.put("Final", 20);
  • 3. WORK_TYPE_TO_WEIGHT_MAP.put("Instructor Discretion", 5); } public static void main(String[] args) throws IOException { Scanner scanner = new Scanner(System.in); ArrayList list = new ArrayList<>(); // List to maintain the rows int index = 1; String avgString = ""; for(String workType : WORK_TYPE_TO_WEIGHT_MAP.keySet()){ System.out.println("Please enter the score for "+workType+": "); int score = scanner.nextInt(); // Create a SSRow and set the parameters SSRow ssRow = new SSRow(); ssRow.setName(workType); ssRow.setScore(score); ssRow.setWeight(WORK_TYPE_TO_WEIGHT_MAP.get(workType)); ssRow.setCal("=B"+index +"*C"+index+"/100"); list.add(ssRow); if(index == 1) avgString +="=D"+index; else avgString+= "+D"+index; index++; } avgString = """+avgString+"""; PrintWriter printer = new PrintWriter(new FileWriter("/home/kumar/Desktop/MyGrades.csv"), true); for(SSRow ssRow : list){ printer.println(ssRow); // Write one row at a time } printer.println(""average", "+avgString); // Append average row scanner.close(); // close the resources after using printer.close(); System.out.println("Program execution completed."); } } import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter;
  • 4. import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.Map; import java.util.Scanner; class SSRow{ String name; int score; int weight; String cal; public String getName() { return name; } public void setName(String name) { this.name = name; } public int getScore() { return score; } public void setScore(int score) { this.score = score; } public int getWeight() { return weight; } public void setWeight(int weight) { this.weight = weight; } public String getCal() { return cal; } public void setCal(String cal) { this.cal = cal; } @Override
  • 5. public String toString() { return """ + name + "", "" + score + "", "" + weight + "", "" + cal + """; } } public class SSWriter { // Maintain a static map b/w workType and weights private static final Map WORK_TYPE_TO_WEIGHT_MAP = new LinkedHashMap<>(); static { WORK_TYPE_TO_WEIGHT_MAP.put("Lab", 20); WORK_TYPE_TO_WEIGHT_MAP.put("Reading Quizzes", 10); WORK_TYPE_TO_WEIGHT_MAP.put("Group Work", 10); WORK_TYPE_TO_WEIGHT_MAP.put("Midterm", 20); WORK_TYPE_TO_WEIGHT_MAP.put("Project", 15); WORK_TYPE_TO_WEIGHT_MAP.put("Final", 20); WORK_TYPE_TO_WEIGHT_MAP.put("Instructor Discretion", 5); } public static void main(String[] args) throws IOException { Scanner scanner = new Scanner(System.in); ArrayList list = new ArrayList<>(); // List to maintain the rows int index = 1; String avgString = ""; for(String workType : WORK_TYPE_TO_WEIGHT_MAP.keySet()){ System.out.println("Please enter the score for "+workType+": "); int score = scanner.nextInt(); // Create a SSRow and set the parameters SSRow ssRow = new SSRow(); ssRow.setName(workType); ssRow.setScore(score); ssRow.setWeight(WORK_TYPE_TO_WEIGHT_MAP.get(workType));
  • 6. ssRow.setCal("=B"+index +"*C"+index+"/100"); list.add(ssRow); if(index == 1) avgString +="=D"+index; else avgString+= "+D"+index; index++; } avgString = """+avgString+"""; PrintWriter printer = new PrintWriter(new FileWriter("/home/kumar/Desktop/MyGrades.csv"), true); for(SSRow ssRow : list){ printer.println(ssRow); // Write one row at a time } printer.println(""average", "+avgString); // Append average row scanner.close(); // close the resources after using printer.close(); System.out.println("Program execution completed."); } } import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.Map; import java.util.Scanner; class SSRow{ String name; int score; int weight; String cal; public String getName() { return name; } public void setName(String name) { this.name = name;
  • 7. } public int getScore() { return score; } public void setScore(int score) { this.score = score; } public int getWeight() { return weight; } public void setWeight(int weight) { this.weight = weight; } public String getCal() { return cal; } public void setCal(String cal) { this.cal = cal; } @Override public String toString() { return """ + name + "", "" + score + "", "" + weight + "", "" + cal + """; } } public class SSWriter { // Maintain a static map b/w workType and weights private static final Map WORK_TYPE_TO_WEIGHT_MAP = new LinkedHashMap<>(); static { WORK_TYPE_TO_WEIGHT_MAP.put("Lab", 20); WORK_TYPE_TO_WEIGHT_MAP.put("Reading Quizzes", 10); WORK_TYPE_TO_WEIGHT_MAP.put("Group Work", 10); WORK_TYPE_TO_WEIGHT_MAP.put("Midterm", 20); WORK_TYPE_TO_WEIGHT_MAP.put("Project", 15); WORK_TYPE_TO_WEIGHT_MAP.put("Final", 20); WORK_TYPE_TO_WEIGHT_MAP.put("Instructor Discretion", 5); }
  • 8. public static void main(String[] args) throws IOException { Scanner scanner = new Scanner(System.in); ArrayList list = new ArrayList<>(); // List to maintain the rows int index = 1; String avgString = ""; for(String workType : WORK_TYPE_TO_WEIGHT_MAP.keySet()){ System.out.println("Please enter the score for "+workType+": "); int score = scanner.nextInt(); // Create a SSRow and set the parameters SSRow ssRow = new SSRow(); ssRow.setName(workType); ssRow.setScore(score); ssRow.setWeight(WORK_TYPE_TO_WEIGHT_MAP.get(workType)); ssRow.setCal("=B"+index +"*C"+index+"/100"); list.add(ssRow); if(index == 1) avgString +="=D"+index; else avgString+= "+D"+index; index++; } avgString = """+avgString+"""; PrintWriter printer = new PrintWriter(new FileWriter("/home/kumar/Desktop/MyGrades.csv"), true); for(SSRow ssRow : list){ printer.println(ssRow); // Write one row at a time } printer.println(""average", "+avgString); // Append average row scanner.close(); // close the resources after using printer.close(); System.out.println("Program execution completed."); } } import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.LinkedHashMap;
  • 9. import java.util.Map; import java.util.Scanner; class SSRow{ String name; int score; int weight; String cal; public String getName() { return name; } public void setName(String name) { this.name = name; } public int getScore() { return score; } public void setScore(int score) { this.score = score; } public int getWeight() { return weight; } public void setWeight(int weight) { this.weight = weight; } public String getCal() { return cal; } public void setCal(String cal) { this.cal = cal; } @Override public String toString() { return """ + name + "", "" + score + "", "" + weight + "", "" + cal + """; } }
  • 10. public class SSWriter { // Maintain a static map b/w workType and weights private static final Map WORK_TYPE_TO_WEIGHT_MAP = new LinkedHashMap<>(); static { WORK_TYPE_TO_WEIGHT_MAP.put("Lab", 20); WORK_TYPE_TO_WEIGHT_MAP.put("Reading Quizzes", 10); WORK_TYPE_TO_WEIGHT_MAP.put("Group Work", 10); WORK_TYPE_TO_WEIGHT_MAP.put("Midterm", 20); WORK_TYPE_TO_WEIGHT_MAP.put("Project", 15); WORK_TYPE_TO_WEIGHT_MAP.put("Final", 20); WORK_TYPE_TO_WEIGHT_MAP.put("Instructor Discretion", 5); } public static void main(String[] args) throws IOException { Scanner scanner = new Scanner(System.in); ArrayList list = new ArrayList<>(); // List to maintain the rows int index = 1; String avgString = ""; for(String workType : WORK_TYPE_TO_WEIGHT_MAP.keySet()){ System.out.println("Please enter the score for "+workType+": "); int score = scanner.nextInt(); // Create a SSRow and set the parameters SSRow ssRow = new SSRow(); ssRow.setName(workType); ssRow.setScore(score); ssRow.setWeight(WORK_TYPE_TO_WEIGHT_MAP.get(workType)); ssRow.setCal("=B"+index +"*C"+index+"/100"); list.add(ssRow); if(index == 1) avgString +="=D"+index; else avgString+= "+D"+index; index++; } avgString = """+avgString+"""; PrintWriter printer = new PrintWriter(new FileWriter("/home/kumar/Desktop/MyGrades.csv"), true); for(SSRow ssRow : list){ printer.println(ssRow); // Write one row at a time
  • 11. } printer.println(""average", "+avgString); // Append average row scanner.close(); // close the resources after using printer.close(); System.out.println("Program execution completed."); } } import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.Map; import java.util.Scanner; class SSRow{ String name; int score; int weight; String cal; public String getName() { return name; } public void setName(String name) { this.name = name; } public int getScore() { return score; } public void setScore(int score) { this.score = score; } public int getWeight() { return weight; }
  • 12. public void setWeight(int weight) { this.weight = weight; } public String getCal() { return cal; } public void setCal(String cal) { this.cal = cal; } @Override public String toString() { return """ + name + "", "" + score + "", "" + weight + "", "" + cal + """; } } public class SSWriter { // Maintain a static map b/w workType and weights private static final Map WORK_TYPE_TO_WEIGHT_MAP = new LinkedHashMap<>(); static { WORK_TYPE_TO_WEIGHT_MAP.put("Lab", 20); WORK_TYPE_TO_WEIGHT_MAP.put("Reading Quizzes", 10); WORK_TYPE_TO_WEIGHT_MAP.put("Group Work", 10); WORK_TYPE_TO_WEIGHT_MAP.put("Midterm", 20); WORK_TYPE_TO_WEIGHT_MAP.put("Project", 15); WORK_TYPE_TO_WEIGHT_MAP.put("Final", 20); WORK_TYPE_TO_WEIGHT_MAP.put("Instructor Discretion", 5); } public static void main(String[] args) throws IOException { Scanner scanner = new Scanner(System.in); ArrayList list = new ArrayList<>(); // List to maintain the rows
  • 13. int index = 1; String avgString = ""; for(String workType : WORK_TYPE_TO_WEIGHT_MAP.keySet()){ System.out.println("Please enter the score for "+workType+": "); int score = scanner.nextInt(); // Create a SSRow and set the parameters SSRow ssRow = new SSRow(); ssRow.setName(workType); ssRow.setScore(score); ssRow.setWeight(WORK_TYPE_TO_WEIGHT_MAP.get(workType)); ssRow.setCal("=B"+index +"*C"+index+"/100"); list.add(ssRow); if(index == 1) avgString +="=D"+index; else avgString+= "+D"+index; index++; } avgString = """+avgString+"""; PrintWriter printer = new PrintWriter(new FileWriter("/home/kumar/Desktop/MyGrades.csv"), true); for(SSRow ssRow : list){ printer.println(ssRow); // Write one row at a time } printer.println(""average", "+avgString); // Append average row scanner.close(); // close the resources after using printer.close(); System.out.println("Program execution completed."); } } import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.Map; import java.util.Scanner;
  • 14. class SSRow{ String name; int score; int weight; String cal; public String getName() { return name; } public void setName(String name) { this.name = name; } public int getScore() { return score; } public void setScore(int score) { this.score = score; } public int getWeight() { return weight; } public void setWeight(int weight) { this.weight = weight; } public String getCal() { return cal; } public void setCal(String cal) { this.cal = cal; } @Override public String toString() { return """ + name + "", "" + score + "", "" + weight + "", "" + cal + """; } } public class SSWriter { // Maintain a static map b/w workType and weights
  • 15. private static final Map WORK_TYPE_TO_WEIGHT_MAP = new LinkedHashMap<>(); static { WORK_TYPE_TO_WEIGHT_MAP.put("Lab", 20); WORK_TYPE_TO_WEIGHT_MAP.put("Reading Quizzes", 10); WORK_TYPE_TO_WEIGHT_MAP.put("Group Work", 10); WORK_TYPE_TO_WEIGHT_MAP.put("Midterm", 20); WORK_TYPE_TO_WEIGHT_MAP.put("Project", 15); WORK_TYPE_TO_WEIGHT_MAP.put("Final", 20); WORK_TYPE_TO_WEIGHT_MAP.put("Instructor Discretion", 5); } public static void main(String[] args) throws IOException { Scanner scanner = new Scanner(System.in); ArrayList list = new ArrayList<>(); // List to maintain the rows int index = 1; String avgString = ""; for(String workType : WORK_TYPE_TO_WEIGHT_MAP.keySet()){ System.out.println("Please enter the score for "+workType+": "); int score = scanner.nextInt(); // Create a SSRow and set the parameters SSRow ssRow = new SSRow(); ssRow.setName(workType); ssRow.setScore(score); ssRow.setWeight(WORK_TYPE_TO_WEIGHT_MAP.get(workType)); ssRow.setCal("=B"+index +"*C"+index+"/100"); list.add(ssRow); if(index == 1) avgString +="=D"+index; else avgString+= "+D"+index; index++; } avgString = """+avgString+"""; PrintWriter printer = new PrintWriter(new FileWriter("/home/kumar/Desktop/MyGrades.csv"), true); for(SSRow ssRow : list){ printer.println(ssRow); // Write one row at a time } printer.println(""average", "+avgString); // Append average row
  • 16. scanner.close(); // close the resources after using printer.close(); System.out.println("Program execution completed."); } }