0% found this document useful (0 votes)
20 views

Programming

The document contains instructions for writing 4 Java programs: 1) to reverse a line of text, 2) to rearrange numbers in ascending order, 3) to perform basic math operations based on a user selection, and 4) to display an error if an invalid option or divide by 0 is selected.

Uploaded by

AAsfaw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Programming

The document contains instructions for writing 4 Java programs: 1) to reverse a line of text, 2) to rearrange numbers in ascending order, 3) to perform basic math operations based on a user selection, and 4) to display an error if an invalid option or divide by 0 is selected.

Uploaded by

AAsfaw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1

Programing Exercise

12/12/2019
2

 Write a java program that prompts a user to enter a


line of text and reverse it.

Sample Output:-
Enter a line of text:- Java is Programming Language
The reversed text is:- egaugnaL gnimmargorP si avaJ

12/12/2019
Exercise
3

 Write java program that prompts a user to enter


different numbers and rearrange them in ascending
order.
Sample output:
Enter no. of elements you want in array: 4
Enter all the elements:
56 32 70 1
Ascending Order:1,32,56,70

12/12/2019
4

 Write a java program that prompts a user for two


integer and prompts the user to enter an option
as follows.
1---to add the numbers
2---to subtract the second from the first
3---to multiple the first by the second
4---to divide the first by the second
 Display an error Message if the user enters an
option other than 1-4 or if the user chooses the
divide option and enter 0 for the second number.

12/12/2019

You might also like