import java.io.File;
import java.io.FileWriter;
import java.util.Scanner;

class QuizMark{
    int id;
    double score;
    QuizMark(int id, double score){
        this.id=id;
        this.score=score;
    }
    int getId(){
        return id;
    }
    double getScore(){
        return score;
    }
    void setId(int id){
        this.id=id;
    }
    void setScore(double score){
        this.score=score;
    }

}
public class Quiz {
    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        int a;
        double b,largest=0;
                QuizMark[] q = new QuizMark[10];
                for(int i=0;i<q.length;i++){
                System.out.print(+i+1+":"+" Write Student's ID: ");
                a=s.nextInt();
                System.out.print("   Write Student's Score: ");
                b=s.nextDouble();
                      if(b>largest)
                      {
                       largest=b;
                      }
                q[i]=new QuizMark(a,b);

                try{
                    FileWriter fw = new FileWriter("QuizMark.txt",true);
                    fw.write(a+": "+b+"");
                    fw.write("\n");
                    fw.close();
                }catch(Exception e){
                    System.out.println(e.getMessage());
                }
                }

               try{
                    File f = new File("QuizMark.txt");
                    s = new Scanner (f);
                    QuizMark[] p = new QuizMark[10];
                    int i = 0;
                    while(s.hasNextLine())

                    {
                        int c = s.nextInt();
                        double d = s.nextInt();
                        p[i]= new QuizMark(c,d);
                        System.out.println(p[i].getId());
                        System.out.println(p[i].getScore());
                        i++;
                    }
                }
                        catch(Exception e){
                            System.out.println(e.getMessage()); 
                            }
               System.out.println("\n\n   The Highest is:"+largest);
            }       
        }

asked 06 Aug '17, 06:22

Muttakinahmed0830's gravatar image

Muttakinahmed0830
71

edited 07 Aug '17, 09:53

menon's gravatar image

menon
4.3k223


কোড ঠিক আছে রান ও করে ।

permanent link

answered 09 Aug '17, 17:40

ShawonAshraf's gravatar image

ShawonAshraf
2345

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×205
×9
×4
×1

question asked: 06 Aug '17, 06:22

question was seen: 285 times

last updated: 09 Aug '17, 17:40