hi
i am answer this question ,
but i didnt know what the errore with cast
represent uppercase letters,
lowercase letters and a considerable variety of special symbols. C++ uses small integers internally to represent each different character.
The set of characters a computer uses and the corresponding integer representations for those characters is called that computer’s
character set. You can print a character by simply enclosing that character in single quotes as with
'A';
You can print the integer equivalent of a character using static_cast as follows:
static_cast< int >( 'A' );
This is called a cast operation. When the preceding statement executes, it prints the
value 65 (on systems that use the ASCII character set). Write a program that prints the integer equivalents of some uppercase letters,
lowercase letters, digits and special symbols.At a minimum, determine the integer equivalents of the following: A B C a b
c 0 1 2 $ * + / and the blank character.

/**
 import java.util.Scanner;
public class letter {

    public static void main(String[] args) {
    	Scanner.input=new Scanner(System.in);
 char symbol;
	System.out.println("Enter a character:");
symbol=input.nextInt();
	System.out.println("Enter a character:");
 	System.out.println(symbol);
 printf("%d , equal to %d ", symbol, static_cast< int > ( symbol ))

    }
}

static_cast< int >( 'A' ); This isn't part of the standard Java language or API, but it is valid C++

You can cast a char to int in Java with the following syntax (int) someChar eg System.out.println('A' + " = " + (int ) 'A' ); // prints A = 65 ... or maybe you should have coded this in C++?

Edited 5 Years Ago by JamesCherrill: n/a

i don't need for one char
if user enter e the output should ba the e=
or if user enter & the output &=
and so on

Edited 5 Years Ago by programing: n/a

I was not going to do your homework for you. I gave you some info you needed, now you have to do some work yourself.
Are you sure whether it's Java or C++ ?

no my dear its not homework ..
i try to learn java for my knowledg about C++
i ask you becaue i think there is a library like Scanner

OK. Yes there is a Scanner class. You almost got it right, the correct syntax is

Scanner input=new Scanner(System.in);

(no . between Scanner and input)

ps: obviously there are other problems in that code, but you will learn more by trying to find and fix them yourself before coming back here for help

Edited 5 Years Ago by JamesCherrill: ps

/**
 * @(#)letter.java
 *
 * letter application
 *
 * @author
 * @version 1.00 2011/3/19
 */
 import java.util.Scanner;
public class letter {

    public static void main(String[] args) {
    	Scanner input=new Scanner(System.in);
 char symbol;
	System.out.println("Enter a character:");
symbol=input.nextChar();
	System.out.println("Enter a character:");
 	System.out.println(symbol);
System.out.println(symbol+(int)symbol);

    }
}
symbol=input.nextChar();

here if i want to read variable have type char
should i modify the statement like above ..


+
mmm
i am read java how to program
are you know other good books .?


>

i am read java how to program
are you know other good books .?
>

Read the ``Starting Java' sticky thread, it contains plenty of useful resources for every programmer learning or using Java.

I not a big user of Scanner myself, so maybe someone else has a better idea, but I think you have to read a String from the Scanner, then pick one or more chars from that String:

String symbols = input.next(); // assume just one symbol is entered
char symbol = symbols.charAt[0];

or you could do a number of symbols all on one line:

String symbols = input.next();
for (int i = 0; i<symbols.length(); i++) {
   char symbol = symbols.charAt[i];
   // do something with symbol
}

As for books - I started learning Java back in the last century, so I don't know what good books there are now. This question has been answered in other threads on this forum, especially http://www.daniweb.com/software-development/java/threads/99132

tux4life
JamesCherrill
Thank the size of the sky
:)


i will try to develop my code ,,,and back if i have question ...

This article has been dead for over six months. Start a new discussion instead.