Computer Science, asked by supreetidebnath597, 5 months ago

write a program to accept N number of decimal values ( in between 0 to 255) in an array .Find out and. store the corresponding character of the integer part of each decimal values in a separate array.display in the following format.
example:
65.4 65 A
[
]
52.89 52 4​

Answers

Answered by rohitkhajuria90
4

Please refer the attached image

Attachments:
Answered by tonystarkironman94
1

Answer:

This is your answer of array to store 10 elements and arrange in descending order

import java.util.Scanner;

public class Descending_Order

{

public static void main(String[] args)

{

int n, temp;

Scanner s = new Scanner(System.in);

System.out.print("Enter no. of elements you want in array:");

n = s.nextInt();

int a[] = new int[n];

System.out.println("Enter all the elements:");

for (int i = 0; i < n; i++)

{

a[i] = s.nextInt();

}

for (int i = 0; i < n; i++)

{

for (int j = i + 1; j < n; j++)

{

if (a[i] < a[j])

{

temp = a[i];

a[i] = a[j];

a[j] = temp;

}

}

}

System.out.print("Descending Order:");

for (int i = 0; i < n - 1; i++)

{

System.out.print(a[i] + ",");

}

System.out.print(a[n - 1]);

}

}

Similar questions