×
Reviews 4.9/5 Order Now

Implement The Use if Arrays and Characters in Java Assignment Solution

July 15, 2024
Aaron O'Donnell
Aaron O'Donnell
🇬🇧 United Kingdom
Java
Aaron O'Donnell, with a Ph.D. from the University of Bristol, United Kingdom, brings 18 years of experience as an Eclipse assignment expert.
Key Topics
  • Instructions
  • Requirements and Specifications
Tip of the day
Always convert images to the correct color space (like BGR ↔ RGB or grayscale) before processing. Many unexpected results come from using the wrong format, especially with filters, edge detection, and object recognition.
News
In 2025, Visual Studio Code rolled out its 1.106 “Agent HQ” update, adding AI-powered coding-agent integration, smarter code completion, and enhanced multi-file editing — a big boost for students and academics doing programming assignments worldwide.

Instructions

Objective

Write a JAVA assignment program to implement arrays to solve problems.

Requirements and Specifications

Program to implement arrays in java

Source Code

#include using namespace std; bool check(int v) { return (-20 <= v) && (v <= 50); } void read15Ints(int* arr, int n) { int counter = 0; int val; while(counter < n) { cin >> val; if (check(val)) { arr[counter] = val; counter++; } else { cout << "Input value is out of bounds" << endl; } } } void showAllBySign(int* arr, int n, bool negative) { cout << (negative ? "Negatives:" : "Non-negatives:"); for (int i = 0; i if (arr[i] < 0 && negative || arr[i] >= 0 && !negative) { cout << " " << arr[i]; } } cout << endl; } void showPositiveSum(int* arr, int n) { cout << "Positive sum:"; int sum = 0; for (int i = 0; i if (arr[i] > 0) { sum += arr[i]; } } cout << sum << endl; } void showArray(int* arr, int n) { cout << "Array:"; for (int i = 0; i cout << " " << arr[i]; } cout << endl; } int main() { int arr[15], n = 15; bool isOver = false; read15Ints(arr, n); while (!isOver) { int choice = 0; cout << "Menu:" << endl; cout << "1. Show all negatives" << endl; cout << "2. Show all non-negatives" << endl; cout << "3. Show positive sum" << endl; cout << "4. Show original array" << endl; cout << "5. Exit" << endl; cout << "Your choice: "; cin >> choice; switch(choice) { case 1: showAllBySign(arr, n, true); break; case 2: showAllBySign(arr, n, false); break; case 3: showPositiveSum(arr, n); break; case 4: showArray(arr, n); break; case 5: isOver = true; break; default: cout << "Invalid input" << endl; break; } cout << endl; } cout << "Good Bye" << endl; }

Related Samples

Explore our Java programming homework samples to see how we tackle complex concepts with clarity and precision. Our curated examples showcase our expertise in Java programming, offering insights into problem-solving, code optimization, and more. Whether you're studying arrays, inheritance, or GUIs, these samples demonstrate our commitment to delivering high-quality solutions tailored to your academic needs.