3 Replies - 176 Views - Last Post: 24 February 2019 - 08:14 AM Rate Topic: -----

#1 TahaAliKhan   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 19-February 19

The program runs fine inintellij but is there any room for development

Posted 19 February 2019 - 02:52 AM

import java.util.Scanner;
import java.util.*;

class Question
{
  String question ;
  int no;
  HashMap<Integer,String> options;
  String correctanswer;

  public static void  q_no(){
    System.out.println("enter a question no");
    int num;
    Scanner no = new  Scanner(System.in);
    num = no.nextInt();
  }
  public static void set_question(){
    System.out.println("enter aquestion");
    Scanner f = new Scanner(System.in);
    String question = f.nextLine();

  }
  public  void set_options(){
    System.out.println("enter options");
    int count = 1;
    options = new HashMap<Integer, String>();
    String q;
    Scanner str = new Scanner(System.in);
    while(count<5){
      System.out.print("set option "+count);
      q= str.nextLine();
      options.put(count,q);
      count++;
    }
  }
  public  void set_correctanswer(){
    System.out.println("enter correct answer");
    Scanner d = new Scanner(System.in);
    String ans = d.nextLine();
  }

  public static void marks(){
  }
}
class Quiz
{
  ArrayList<Question> list = new ArrayList<Question>();
  public ArrayList<Question> adding(Question q){
    list.add(q);
    return list;
  }
  public void show(){
    int g = list.size();
    int count =0;

    //while(count<g){>
    //  list.get(count);
    //}
  }
}

class Menu{
  public static void main(String[] args) {
    System.out.println("enter 1 for adding questions");
    Scanner input = new Scanner(System.in);
    int g;
    g= input.nextInt();
    if (g == 1){
      System.out.println("how many questions do you add");
      int number;
      Scanner b = new Scanner(System.in);
      Quiz programming = new Quiz();
      number = b.nextInt();
      int count=0;
      while(count<number){//>
        Question q1 = new Question();
        q1.q_no();
        q1.set_question();
        q1.set_options();
        q1.set_correctanswer();
        programming.adding(q1);
        ++count;
      }
    }
    else if(g ==2){
      Quiz programming = new Quiz();
      programming.show();
    }
  }
}

This post has been edited by ndc85430: 19 February 2019 - 02:55 AM
Reason for edit:: Added "[CODE]" tags. Please do this yourself in future.


Is This A Good Question/Topic? 0
  • +

Replies To: The program runs fine inintellij but is there any room for development

#2 andrewsw   User is offline

  • Stealth IT
  • member icon

Reputation: 6744
  • View blog
  • Posts: 27,758
  • Joined: 12-December 12

Re: The program runs fine inintellij but is there any room for development

Posted 19 February 2019 - 03:08 AM

Is there anything in particular that you think could be improved? Anything that irks you?
Was This Post Helpful? 0
  • +
  • -

#3 TahaAliKhan   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 19-February 19

Re: The program runs fine inintellij but is there any room for development

Posted 24 February 2019 - 06:38 AM

View Postandrewsw, on 19 February 2019 - 03:08 AM, said:

Is there anything in particular that you think could be improved? Anything that irks you?

yea if i add joption pane instead of scanner?
Was This Post Helpful? 0
  • +
  • -

#4 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3617
  • View blog
  • Posts: 16,596
  • Joined: 20-September 08

Re: The program runs fine inintellij but is there any room for development

Posted 24 February 2019 - 08:14 AM

If you had a GUI app, yes. But you haven't so Scanner is better
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1