Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 1: Program to understand the basic output statements in java Code: public class exc_1 { public static void main(String[] args) { // TODO code

image text in transcribed
image text in transcribed
Exercise 1: Program to understand the basic output statements in java Code: public class exc_1 { public static void main(String[] args) { // TODO code application logic here System.out.println("Welcome to Java Programming"); System.out.print("Hello World"); System.out.print("first program"); } } Exercise 2: Program to understand the concept of variables public class Example public static void main(String[] args) { String text = "contains text": int wholeNumber = 123; double floating Point = 3.141592653; boolean trueOrFalse = true; System.out.println("Text variable: " + text); System.out.println("Integer variable: " + wholeNumber); System.out.println("Floating-point variable:" + floating Point); System.out.println("Boolean:" + trueOrFalse); } } Exercise 3: Program to get an input from the user using Scanner Class // Introduce the scanner tool used for reading user input import java.util.Scanner public class Program public static void main(String[] args) { // Create a tool for reading user input and name it scanner Scanner scanner new Scanner(System.in); // Print Write a message: System.out.println("Write a message: "); W/ Read the string written by the user, and assign it // Read the string written by the user, and assign it String message = scanner.nextLine(); System.out.println("Enter a number); int number = scanner.nextInt(); System.out.println("Enter a Mark); double mark = scanner.nextInt(); // Print the message written by the user System.out.println(message); System.out.println(number); System.out.println(mark); } Exercise 4: Program to find the ASCII value of a character public class Ascii Value { public static void main(String[] args) { char ch = 'a'; int ascii =ch; // You can also cast char to int int castAscii = (int) ch; System.out.println("The ASCII value of " + ch + "is:" + ascii); System.out.println("The ASCII value of " + ch + "is:" + castAscii); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions