Bookmark Topic Watch Topic
  • New Topic

Java adding infinte strings

 
Ben Peer
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Report post to moderator
This is the code i have and i need to find a way to add the data inputed together so its all one string like the count++ thing where it adds to the count for each input. so if a 'd' then 'f' then '$' is input the it would add them together in the variable "mixTotal = df$"ot sure how to do this so that it can add strings even if there are 50 or 40 entered.



 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Report post to moderator
You need to add each character to mixTotal inside the loop. You are doing it once afetr the loop has exited. You were closer with your attempt in your first post.

It is better to add any further questions to this post rather than starting a new thread each time - that way everyone can easily see what you have already tried and what suggestions have been made.
 
Vineet Kakati
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Report post to moderator
I would suggest using a character array to enter characters one by one;
I would also suggest the use of functions toUpperCase() and toLowerCase for each entered character;
After entering ,the array should be printed;
Continue entering characters till entered character is not '.';

Refer the changes made to your code as shown below:-
 
Campbell Ritchie
Sheriff
Pie
Posts: 50289
80
  • Mark post as helpful
  • send pies
  • Report post to moderator
Joanne Neal wrote: . . . It is better to add any further questions to this post rather than starting a new thread each time - that way everyone can easily see what you have already tried and what suggestions have been made.
Agree with Joanne (nice to see you again, by the way, Joanne), so I shall close this thread.
 
    Bookmark Topic Watch Topic
  • New Topic