java - Cannot find Symbol for char -


this question has answer here:

school assignment, code meaningless. whenever try use char, seem error

letsgoshop.java:14: error: cannot find symbol                        item = input.nextchar();                                    ^   symbol:   method nextchar()   location: variable input of type scanner   1 error 

heres actual code :

import java.util.scanner;  public class letsgoshop {      public static void main(string[] args) {          java.util.scanner input = new java.util.scanner(system.in);          char item ;         int price;         int quantity;          system.out.println(" enter name of item : ");         item = input.nextchar();         system.out.println(" enter price of said item : ");         price = input.nextint();         system.out.println(" enter how of said item want buy : ");         quantity = input.nextint();          double total = price * quantity ;         item = character.touppercase(item);          system.out.println(" owe " +total+ " " +quantity + item);      }  } 

i beginning code, if answers obvious, wouldn't have guessed it.

since nextchar does not exist, offer consider trying following:

char item; item = input.next().charat(0); 

edit: understand, want this:

string item = input.next(); string newitem = input.substring(0, 1).touppercase() + input.substring(1); 

this take string (item name) user, , make first letter uppercase.

if want make sure other letters lower case, use:

string newitem = input.substring(0, 1).touppercase() + input.substring(1).tolowercase(); 

edit #2: capitalize entire word:

string item = input.next().touppercase(); 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -