Inked235345364566556546_LI.jpg
Sample output:

Enter number of guests: 40

40 guests have been invited.

Enjoy the party!

Dani AI

Generated

Two separate problems are visible in the thread: a small input/output exercise posted by and a larger file-parsing/menu exercise from . Below are concise, practical starting points and common pitfalls so each can be implemented cleanly without over‑engineering. References to other replies are noted: 's point about using a base class for reusable party types is a good design reminder, and 's link to the community rules is relevant for posting code/attempts.

For the small I/O task (prompt for a number, validate it, print responses) aim for minimal, robust code. Example C++ (console) and Node.js (console) starters:

#include <iostream>
#include <limits>

int main() {
    int n;
    std::cout << "Enter number of guests: ";
    while (!(std::cin >> n) || n < 0) {
        std::cin.clear();
        std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
        std::cout << "Please enter a non-negative integer: ";
    }
    std::cout << n << " guests have been invited.\nEnjoy the party!\n";
    return 0;
}
const readline = require('readline').createInterface({ input: process.stdin, output: process.stdout });
readline.question('Enter number of guests: ', ans => {
  const n = parseInt(ans, 10);
  if (isNaN(n) || n < 0) console.log('Please enter a non-negative integer.');
  else { console.log(`${n} guests have been invited.`); console.log('Enjoy the party!'); }
  readline.close();
});

For the file-parsing/menu assignment, prefer modelling records (a Car class or record) and using a dynamic collection (ArrayList<Car>) for clarity; if the brief insists on parallel arrays, populate ArrayLists for each column and convert to fixed arrays after reading. Typical steps: read and parse the first two lines (headers and types), choose parsers per column (Integer.parseInt, Double.parseDouble, or keep String), read remaining lines splitting on the file delimiter, store values consistently, then implement menu options as small functions that iterate/filter/sort the collection.

Common pitfalls: inconsistent delimiters, blank lines, NumberFormatException for missing/non-numeric fields, off‑by‑one indexing when using parallel arrays, and forgetting to close file handles. If planning future extensions (different party types or more car queries), follow and design simple base classes or clear modules so new features plug in cleanly.

I need help with this question

Refer to the file cars_data.txt. It consists of a dataset of about 400 cars with 8 characteristics such as horsepower, acceleration,etc. The first line contains the different details that are stored in the file and the second line contains the data type for each information. As from the third line the actual values about the 8 characteristics are stored.

You are required to write a complete Java program that will:

(a) Create 8 parallel arrays to store 8 information pieces about the 400 cars or two-dimensional arrays, using the type provided in the second line, in the main() function

(b) Read the file cars_data.txt and fill the 8 arrays created in (a); you may use a function for that.

(c) Provide a menu to the user with following options:

  1. Search by car model (e.g. Toyota, Chevrolet, ...)
  2. Search by country of origin
  3. List car/s with maximum horsepower
  4. List car/s with maximum acceleration
  5. List car/s with minimum weight
  6. Exit
    The menu will run in a loop such that after running an option the menu will re-appear until user chooses to exit. You are required to write a function to implement options 1 to 5 and use a switch case construct.

(d) create a main function which will call the functions in (c)

A case where inheritance is obviously appropriate. You want a base class of Party from which BdayParty inherits. Different languges have differences in how to do object oriented design. C++ is straightforward but in Javascript I'd make a module for the BdayParty to use another module named Party internally if I was interested in other parties later. If it is a one-off program to solve a particular problem I'd not bother with inheritance and just make one class or module.

commented: Fail. Answer has zero relevance to the question. -3

It would have been very interesting to see an attempt on answering the above

commented: No question was asked. It seems to be one of those "dump my homework and hope someone does it for me" posts. +15
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.