Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.Scanner;
- public class TestTutorialMark{
- public static void main(String[] args){
- Scanner scan = new Scanner(System.in);
- TutorialMark person = new TutorialMark("", "", "", "");
- System.out.print("Enter student's name: ");
- person.setName(scan.nextLine());
- System.out.print("Enter student's tutorial: ");
- person.setTutorial(scan.nextLine());
- System.out.print("Enter number of questions: ");
- person.setQuestions(scan.nextLine());
- System.out.println("# Enter questions in format: passed,total,value");
- ArrayList<String> list = new ArrayList<String>();
- double score;
- double total;
- double numQuestion;
- double avg = 0;
- double grandTotal = 0;
- for(int i = 0; i < Integer.parseInt(person.getQuestions()); i++){
- System.out.print("Enter Q" + (i +1) + ": ");
- list.add(scan.nextLine());
- }
- System.out.println("\n# Moodle Summary");
- System.out.println(person.getName() + " - " + person.getTutorial());
- for(int i = 0; i < list.size(); i++ ){
- if(list.sub){
- score = Integer.parseInt(list.get(i).substring(0,1));
- total = Integer.parseInt(list.get(i).substring(2,3));
- numQuestion = Integer.parseInt(list.get(i).substring(4,6));
- avg = (score/total) * numQuestion;
- grandTotal += avg;
- System.out.println("Q" + (i+1) + " (" + String.format("%.0f", score) + "/" + String.format("%.0f", total) + ") " + String.format("%.1f", avg));
- }
- else{
- score = Integer.parseInt(list.get(i).substring(0,1));
- total = Integer.parseInt(list.get(i).substring(2,3));
- numQuestion = Integer.parseInt(list.get(i).substring(4,5));
- avg = (score/total) * numQuestion;
- grandTotal += avg;
- System.out.println("Q" + (i+1) + " (" + String.format("%.0f", score) + "/" + String.format("%.0f", total) + ") " + String.format("%.1f", avg));
- }
- }
- System.out.println("\nTotal: " + grandTotal);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement