4 Replies - 235 Views - Last Post: 04 February 2018 - 02:19 PM Rate Topic: -----

#1 jin999  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 04-February 18

how can i show and proceed previous dialog?

Posted 04 February 2018 - 04:19 AM

Hello, I have just started learning java.

Running this code firstly shows texts in String mainmen', and press 'C' allows to input data.
Here, I have a problem that i cannot proceed,
Firstly, I want to save the data that input by an user.
Then I want to show the texts in String mainmenu again, and works in the same way as it has started (maybe data is saved as input by an user?).
Please help me T.T




import java.util.Scanner;

public class ppp {
    
  public static void main(String[] args) {
    
    Scanner scan = new Scanner(System.in);
    
    String mainmenu = "\n\tWelcome to Split-it\n\n\t\tAbout (A)\n\t\tCreate Project (C)\n\t\tEnter Votes (V)\n\t\tShow Projext (S)\n\t\tQuit (Q)\n\n\t\tPlease choose an option: ";
    System.out.print(mainmenu);

    char acvsq = scan.next().charAt(0);

if (acvsq == 'a' || acvsq == 'A'){
 System.out.println("ABout blabla");
 }
 
else if (acvsq == 'c' || acvsq == 'C'){
 System.out.print("\n\tEnter the project name: ");
 char projectname = scan.next().charAt(0);
 
 System.out.print("\tEnter the number of team members: ");
 int teammembers = scan.nextInt();
 System.out.println();
 
 int numberoflines = 1;
 
 while (numberoflines <= teammembers){
 System.out.print("\t\tEnter the name of team member " + numberoflines + ": ");
 char member = scan.next().charAt(0);
 numberoflines++;
 }
 
 System.out.println();
 System.out.println("Press any key to return to the main menu: ");
 try {
   System.in.read();
 }
  catch(Exception e)
  {}
 }

  
 
    else if (acvsq == 'q' || acvsq == 'Q'){ 
   System.out.println();
   System.out.println("\tThe application is end\n");
   return; 
 }
 
 
    
 else if (acvsq == 'v' || acvsq == 'V'){ 
    }

 else if (acvsq == 's' || acvsq == 'S'){ 
    }  
 
}
}




Is This A Good Question/Topic? 0
  • +

Replies To: how can i show and proceed previous dialog?

#2 NormR  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 691
  • View blog
  • Posts: 5,267
  • Joined: 25-December 13

Re: how can i show and proceed previous dialog?

Posted 04 February 2018 - 07:39 AM

Quote

I have a problem that i cannot proceed,

Can you explain what the program does now
and how you want to change it.

Note: The code's formatting needs to be fixed so that nested statements are properly indented to show the program's logic.
Was This Post Helpful? 1
  • +
  • -

#3 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3541
  • View blog
  • Posts: 16,135
  • Joined: 20-September 08

Re: how can i show and proceed previous dialog?

Posted 04 February 2018 - 08:19 AM

Quote

  char acvsq = scan.next().charAt(0);


That's a poor name for a variable. You would be better using switch subsequently. So


char choice = Character.toUpperCase(scan.next().charAt(0));
switch (choice) {
   case 'A':
       // etc
}

Was This Post Helpful? 1
  • +
  • -

#4 jin999  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 04-February 18

Re: how can i show and proceed previous dialog?

Posted 04 February 2018 - 02:13 PM

View PostNormR, on 04 February 2018 - 07:39 AM, said:

Quote

I have a problem that i cannot proceed,

Can you explain what the program does now
and how you want to change it.

Note: The code's formatting needs to be fixed so that nested statements are properly indented to show the program's logic.



The code i wrote works at start.
That sentence was my mistake and meaning that, how can i show the string mainmenu again, without rewriting string when any key or v / s are typped.

Also, which part whithin whole code, should i add filewriter to create a txt file of what user write?
Was This Post Helpful? 0
  • +
  • -

#5 NormR  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 691
  • View blog
  • Posts: 5,267
  • Joined: 25-December 13

Re: how can i show and proceed previous dialog?

Posted 04 February 2018 - 02:19 PM

Quote

which part whithin whole code, should i add filewriter to create a txt file of what user write?

That could be done after the user's input has been received and verified.

I'm waiting until the code has been properly formatted before I try to read it.

This post has been edited by NormR: 04 February 2018 - 02:19 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1