JAVA Introduction course Create a variable of type char and name it dash Assign
ID: 671910 • Letter: J
Question
JAVA Introduction course
Create a variable of type char and name it dash
Assign it a value fitting the name
Use printf to display the variable. Make sure to include a label
In the following statements you will declare and assign a number of variables:
Assign the literal ‘a’ to variable named a
Assign the variable a to a variable named letter
In a single statement do the following:
Use the prefix increment to increase the value of the variable letter by one and assign it to the variable b
Use the prefix increment to increase the value of the variable letter by one and assign it to the variable c
Use a compound operator to add 2 to the variable letter
Assign the value of the variable letter to the variable e
Use a printf statement to print the values of letter, a, b, c, and d ( use labels )
Look up the hexadecimal number that corresponds to © (Copyright sign)
Resource: https://en.wikipedia.org/wiki/C1_Controls_and_Latin-1_Supplement
Assign the Unicode sequence that corresponds to © to a variable named copyrightSign
Use a printf statement to print the value of copyrightSign ( as a symbol) as well as the number corresponding
to © both as decimal and hexadecimal value
Assign the a character literal '¥' to a variable named yen
Use a printf statement to print the value of yen ( as a symbol) as well as the number corresponding to ¥ both as
decimal and hexadecimal value
Output:
Dash:- Letter:e a:a b:b c:c e:e
Copyright sign: © 169 A9
Yen: ¥ 165 A5
Explanation / Answer
working java code
/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
char dash;
dash = 'v';
System.out.println(dash);
char a,b,c,e;
a='a';
b=a++;
c=b++;
e=c;
e+=2;
System.out.println("Dash:- Letter:"+dash+ " a:"+a+" b:"+b +" c:"+ c +" e:" +e);
char copyright;
copyright = 'u00A9';
System.out.println("Copyright sign: " + copyright + " 169 A9");
char yen;
yen = 'u00A5';
System.out.println("Yen: " + yen + "165 A5");
}
}
compiled on ideone
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.