Cannot incorporate equals method for a yes or no answer.

Reply

Join Date: Oct 2004
Posts: 1
Reputation: ytrula is an unknown quantity at this point 
Solved Threads: 0
ytrula ytrula is offline Offline
Newbie Poster

Cannot incorporate equals method for a yes or no answer.

 
0
  #1
Oct 20th, 2004
I was hoping that someone could show me how to use the equals method to change numbers that were entered. Three numbers are entered and the user is asked if they need to change a number. This is followed by a yes or no. It says if the answer is yes to change the number, to use the equals method. This is donethree times by once changing the number, adding a number and removing a number. Please help! Thanks Ytula
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: Cannot incorporate equals method for a yes or no answer.

 
0
  #2
Oct 20th, 2004
Your question is somewhat unclear. But maybe I got it right. I posted code what I thought you were wanting if it's not let me know...

  1. import java.io.*;
  2.  
  3. class NumbersandInput
  4. {
  5. public static void main(String[] args) throws IOException
  6. {
  7. BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  8. String inData;
  9. int i;
  10. int i2;
  11.  
  12. System.out.println("Please enter an integer");
  13. i = Integer.parseInt(br.readLine());
  14. i2 = i;
  15. System.out.println("\n Would you like to change the number?");
  16.  
  17. inData = br.readLine();
  18. if (inData.equals("Yes"))
  19. {
  20. try {
  21. System.out.println("\n What would you like to change it to?");
  22. i2 = Integer.parseInt(br.readLine());
  23. }
  24. catch (NumberFormatException e) {}
  25. }
  26. else {
  27. System.out.println("No change was made");
  28. }
  29.  
  30. System.out.println(" \n \n \n The staring value of the integer was: " + i);
  31. System.out.println(" The eding value of the integer was: " + i2);
  32.  
  33.  
  34. }
  35. }
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC