JAVA_CODINGS Telegram 79
59. Middle value of an array.

import java.util.*;

class MiddleValue
{
public static void main(String args[])
{
int[] a;
int i, j, n, sum = 0, swap, size;

double t;
Scanner sc = new Scanner(System.in);

System.out.println("Enter size of array");
size = sc.nextInt();

a = new int[size];

System.out.println("Enter numbers ");
for (i = 0; i < size; i++)
{
a[i] = sc.nextInt();
}

System.out.println("Numbers are : ");
for (i = 0; i < size; i++)
{
System.out.print(a[i] + " ");
}

//Sorting
for (i = 0; i < (size - 1); i++)
{
for (j = 0; j < (size - i - 1); j++)
{
if (a[j] > a[j + 1])
{
swap = a[j];
a[j] = a[j + 1];
a[j + 1] = swap;
}
}
}

System.out.println("\nNumbers in sorted order : ");
for (i = 0; i < size; i++)
{
System.out.print(a[i] + " ");
}

//Finding the Middle Value
if (size % 2 == 0)
{
n = (size + 1) / 2;
t = (a[n] + a[n - 1]) / 2.0;
System.out.println("\nMiddle Value is : " + t);
}

else
{
System.out.println("\nMiddle Value is : " + a[size / 2]);
}

}
}

@java_codings



tgoop.com/java_codings/79
Create:
Last Update:

59. Middle value of an array.

import java.util.*;

class MiddleValue
{
public static void main(String args[])
{
int[] a;
int i, j, n, sum = 0, swap, size;

double t;
Scanner sc = new Scanner(System.in);

System.out.println("Enter size of array");
size = sc.nextInt();

a = new int[size];

System.out.println("Enter numbers ");
for (i = 0; i < size; i++)
{
a[i] = sc.nextInt();
}

System.out.println("Numbers are : ");
for (i = 0; i < size; i++)
{
System.out.print(a[i] + " ");
}

//Sorting
for (i = 0; i < (size - 1); i++)
{
for (j = 0; j < (size - i - 1); j++)
{
if (a[j] > a[j + 1])
{
swap = a[j];
a[j] = a[j + 1];
a[j + 1] = swap;
}
}
}

System.out.println("\nNumbers in sorted order : ");
for (i = 0; i < size; i++)
{
System.out.print(a[i] + " ");
}

//Finding the Middle Value
if (size % 2 == 0)
{
n = (size + 1) / 2;
t = (a[n] + a[n - 1]) / 2.0;
System.out.println("\nMiddle Value is : " + t);
}

else
{
System.out.println("\nMiddle Value is : " + a[size / 2]);
}

}
}

@java_codings

BY Advance Java 👨‍💻


Share with your friend now:
tgoop.com/java_codings/79

View MORE
Open in Telegram


Telegram News

Date: |

There have been several contributions to the group with members posting voice notes of screaming, yelling, groaning, and wailing in different rhythms and pitches. Calling out the “degenerate” community or the crypto obsessives that engage in high-risk trading, Co-founder of NFT renting protocol Rentable World emiliano.eth shared this group on his Twitter. He wrote: “hey degen, are you stressed? Just let it out all out. Voice only tg channel for screaming”. The initiatives announced by Perekopsky include monitoring the content in groups. According to the executive, posts identified as lacking context or as containing false information will be flagged as a potential source of disinformation. The content is then forwarded to Telegram's fact-checking channels for analysis and subsequent publication of verified information. The optimal dimension of the avatar on Telegram is 512px by 512px, and it’s recommended to use PNG format to deliver an unpixelated avatar. It’s yet another bloodbath on Satoshi Street. As of press time, Bitcoin (BTC) and the broader cryptocurrency market have corrected another 10 percent amid a massive sell-off. Ethereum (EHT) is down a staggering 15 percent moving close to $1,000, down more than 42 percent on the weekly chart. Developing social channels based on exchanging a single message isn’t exactly new, of course. Back in 2014, the “Yo” app was launched with the sole purpose of enabling users to send each other the greeting “Yo.”
from us


Telegram Advance Java 👨‍💻
FROM American