The following print code is to find out the ASCII code, character for the decimal codes,and comparison of characters. Use the ASCII chart to figure out what will be printed andverify it via Eclipse. System.out.println((int)'1');System.out.println((int)'A');System.out.println((int)'a');System.out.println((char)40);System.out.println((char)59);System.out.println((char)64);System.out.println('a' < 'b');System.out.println('a' <= 'A');System.out.println('a' == 'a');System.out.println('a' != 'b');2. Write a program called Convert, which converts an ASCII code to its equivalentcharacter. 1) Create a Scanner2) Declare a variable of type int3) Ask the user to enter the ASCII code (type int)4) Print the ASCII equivalentNote: Use casting to cast the int to a char.Submission Copy and paste your code Screen shot the console with user input of two example inputsSample RunsEnter an ASCII code65The character for ASCII code 65 is AEnter an ASCII code74The character for ASCII code 74 is J

Question
Asked Feb 28, 2019
22 views

The following print code is to find out the ASCII code, character for the decimal codes,
and comparison of characters. Use the ASCII chart to figure out what will be printed and
verify it via Eclipse. 
System.out.println((int)'1');
System.out.println((int)'A');
System.out.println((int)'a');
System.out.println((char)40);
System.out.println((char)59);
System.out.println((char)64);
System.out.println('a' < 'b');
System.out.println('a' <= 'A');
System.out.println('a' == 'a');
System.out.println('a' != 'b');
2. Write a program called Convert, which converts an ASCII code to its equivalent
character. 
1) Create a Scanner
2) Declare a variable of type int
3) Ask the user to enter the ASCII code (type int)
4) Print the ASCII equivalent
Note: Use casting to cast the int to a char.
Submission
 Copy and paste your code
 Screen shot the console with user input of two example inputs
Sample Runs
Enter an ASCII code
65
The character for ASCII code 65 is A
Enter an ASCII code
74
The character for ASCII code 74 is J

check_circle

Expert Answer

Step 1

Reasons for displaying given output for each line of code:

 

For “System.out.println((int)'1');”:

 

From the given line, the “(int)'1'” implies decimal code for character “1”.

  • Hence, the decimal code for character “1” from the ASCII chart is “49”.

 

For “System.out.println((int)'A');”:

 

From the given line, the “(int)'A'” implies decimal code for character “A”.

  • Hence, the decimal code for character “A” from the ASCII chart is “65”.

 

For “System.out.println((int)'a');”:

 

From the given line, the “(int)'a'” implies decimal code for character “A”.

  • Hence, the decimal code for character “A” from the ASCII chart is “97”.

 

For “System.out.println((char)40);”:

 

From the given line, the “(char)40” implies character code for decimal value “40”.

  • Hence, the character code for decimal value “40” from the ASCII chart is “(”.

 

For “System.out.println((char)59);”:

 

From the given line, the “(char)59” implies character code for decimal value “59”.

  • Hence, the character code for decimal value “59” from the ASCII chart is “;”.

 

For “System.out.println((char)64);”:

 

From the given line, the “(char)64” implies character code for decimal value “64”.

  • Hence, the character code for decimal value “64” from the ASCII chart is “@”.

 

For “System.out.println('a' < 'b');”:

 

From the given line, the condition “'a' < 'b'” implies decimal code of character “a” is less than the decimal code of character “b”.

  • From the ASCII chart, the decimal code for character “a” is “97” and decimal code of character “b” is “98”.
  • Hence, the comparison condition “'a' < 'b'” implies “97 < 98” which is true. Therefore, the given line prints “true”.

 

For “System.out.println('a' <= 'A');”:

 

From the given line, the condition “'a' <= 'A'” implies decimal code of character “a” is less than or equal to the decimal code of character “A”.

  • From the ASCII chart, the decimal code for character “a” is “97” and decimal code of character “A” is “65”.
  • Hence, the comparison condition “'a' <= 'A'” implies “97 <= 65” which is false. Therefore, the given line prints “false”.

 

For “System.out.println('a' == 'a');”:

 

From the given line, the condition “'a' == 'a'” implies decimal code of character “a” is equal to the decimal code of character “a”.

  • From the ASCII chart, the decimal code for character “a” is “97”.
  • Hence, the comparison condition “'a' == 'a'” implies “97 == 97” which is true. Therefore, the given line prints “true”.

 

For “System.out.println('a' != 'b');”:

 

From the given line, the condition “'a' != 'b'” implies decimal code of character “a” is not equal to the decimal code of character “b”.

  • From the ASCII chart, the decimal code for character “a” is “97” and decimal code of character “b” is “98”.
  • Hence, the comparison condition “'a' != 'b'” implies “97 != 98” which is true. Therefore, the given line prints “true”.
Step 2

The verified output for above all lines of code is given below:

fullscreen
Step 3

2. Java Program for convert the ASCII code to its equivalent character:

//Import package for Scanner class
import java.util.Scanner;
 
//Define a class "Convert"
public class Convert
{
    //Main function
    public static void main(String[] args) 
    {
        //Create scanner class
        Scanner s = new Scanner(System.in);
        
        /* Declare integer variable "asciiCode" */
  int asciiCode;
        
        /* Display user prompt message */
        System.out.println("Enter an ASCII code ");
 
        /* Read t...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Engineering

Programing

Related Computer Engineering Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: “Performance” or “response time.” defines how fast an application presents an output once given an i...

A: Performance bottleneck:It is defined as a condition in a system which can cause delays or slow down ...

question_answer

Q: Consider the window size is 10, bandwidth is 1500 bps, transmission delay is 2 ms and propagation de...

A: Formula for Throughput:In Go-back-N protocol, the formula for computing the throughput is given belo...

question_answer

Q: Imagine you’d like a contractor to build a software application for you that operates like Windows C...

A: Statement of objectives (SOO):It provides an overall objective which serves as the basis for the sta...

question_answer

Q: WRITE A JAVA PROGRAM that perform the Insertion Sort, Bubble Sort, Merge Sort, and Quick Sort algori...

A: Program Instructions:Create four methods named insertionSort(), bubblesort(), mergesort() and quicks...

question_answer

Q: how can I create comments in python?

A: In python, # character is used to start the single line comments. Place a hash symbol in front of a ...

question_answer

Q: Imagine you’d like a contractor to build a software application for you that operates like Windows C...

A: Since there are multiple questions and no specification as to which question needs to be solved, her...

question_answer

Q: Describe two concepts for an autonomous transportation and/or delivery that replaces manned systems....

A: Autonomous transportation is the evolution of transport where the vehicles are connected to create a...

question_answer

Q: how to implement a KMS system at any firm where employees can use it but not depend on it

A: Ans. Knowledge management system:Knowledge management system deals with storing and managing data or...

question_answer

Q: Which of the following code is used to check the web worker object is exists or not? if the web work...

A: The below given code snippet is used to check whether the web worker object is exist or not and if t...