0% found this document useful (0 votes)
4 views2 pages

Quize #2

The document contains two Java programs. The first program reverses a three-digit number input by the user, while the second program calculates the sum of the tenth and last digits of a five-digit number entered by the user. Both programs utilize the Scanner class for user input.

Uploaded by

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

Quize #2

The document contains two Java programs. The first program reverses a three-digit number input by the user, while the second program calculates the sum of the tenth and last digits of a five-digit number entered by the user. Both programs utilize the Scanner class for user input.

Uploaded by

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

Q#1

import java.util.Scanner;

public class Main{

public static void main(String[] args)

int a,b;

int m=0;

Scanner input=new Scanner(System.in);

System.out.println("enter the three digit numner to revese");

a=input.nextInt();

while(a>0) {

b=a%10;

a=a/10;

m=(m*10)+b;

System.out.println("the reverse of the number is"+m);

Q#2

import java.util.Scanner;

public class ten{

public static void main(String[] args) {


int number;

int sum=0;

int k=0, t=0;

Scanner input = new Scanner(System.in);

System.out.println("Enter a five-digit number: ");

number = input.nextInt();

number=number/10;

k=number%10;

t=(number/1000)%10;

sum = k+t;

System.out.println("The sum of the tenth digit and the last digit is: " + sum);

You might also like