Please convert this code into C language (#include Main.java import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); ArrayList planes = new ArrayList(); while (true) { System.out.print("\nAdd a plane (a)?\nRemove a plane (r)?\nSearch for plane (s)? \nQuit (q) \n"); String choice = sc.nextLine(); if (choice.equalsIgnoreCase("q")) break; else if (choice.equalsIgnoreCase("a")) { String pname; int nos; System.out.print("Enter name of plane: "); pname = sc.nextLine(); System.out.print("Enter num of seats in plane: "); nos = sc.nextInt(); Plane p = new Plane(nos, pname); System.out.print("Enter no. of Passengers on Monday: "); int nop = sc.nextInt(); p.addFlights(nop, "Monday"); System.out.print("Enter no. of Passengers on Tuesday: "); int not = sc.nextInt(); p.addFlights(not, "Tuesday"); System.out.print("Enter no. of Passengers on Wednesday: "); int now = sc.nextInt(); p.addFlights(now, "Wednesday"); System.out.print("Enter no. of Passengers on Thursday: "); int noth = sc.nextInt(); p.addFlights(noth, "Thursday"); System.out.print("Enter no. of Passengers on Friday: "); int nof = sc.nextInt(); p.addFlights(nof, "Friday"); System.out.print("Enter no. of Passengers on Saturday: "); int nosa = sc.nextInt(); p.addFlights(nosa, "Saturday"); planes.add(p); System.out.print("Added a new Plane!\n"); } else if (choice.equalsIgnoreCase("r")) { System.out.print("Enter name of plane to remove: "); String remP = sc.next(); for (int i = 0; i < planes.size(); i++) { if (planes.get(i).getName().equalsIgnoreCase(remP)) { planes.remove(i); System.out.print("Removed a Plane!\n"); } } } else if (choice.equalsIgnoreCase("s")) { System.out.print("Enter num of Passengers: "); int searchP = sc.nextInt(); ArrayList f; for (int i = 0; i < planes.size(); i++) { f = planes.get(i).getFlights(); for (int j = 0; j < f.size(); j++) { if (f.get(j).getNOP() == searchP) { System.out.print("\nThe plane is: " + planes.get(i).getName()); System.out.print("\nThe day is: " + f.get(j).getDay()); } } } } } } } arrow_forward Plane.java import java.util.*; public class Plane { int noOfSeats; String name; ArrayList flights; public Plane(int noOfSeats, String name) { this.noOfSeats = noOfSeats; this.name = name; flights = new ArrayList(); } public void addFlights(int nop, String day) { Flight f = new Flight(day, nop); flights.add(f); } public String getName() { return this.name; } public ArrayList getFlights() { return this.flights; } } arrow_forward Flight.java public class Flight { int noOfPassengers; String day; public Flight(String day, int noOfPassengers) { this.noOfPassengers = noOfPassengers; this.day = day; } public int getNOP() { return noOfPassengers; } public String getDay() { return day; } }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Please convert this code into
C language (#include <stdio.h>

Main.java

import java.util.*;

class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
ArrayList<Plane> planes = new ArrayList<Plane>();

while (true) {

System.out.print("\nAdd a plane (a)?\nRemove a plane (r)?\nSearch for plane (s)? \nQuit (q) \n");
String choice = sc.nextLine();
if (choice.equalsIgnoreCase("q"))
break;
else if (choice.equalsIgnoreCase("a")) {
String pname;
int nos;
System.out.print("Enter name of plane: ");
pname = sc.nextLine();
System.out.print("Enter num of seats in plane: ");
nos = sc.nextInt();
Plane p = new Plane(nos, pname);
System.out.print("Enter no. of Passengers on Monday: ");
int nop = sc.nextInt();
p.addFlights(nop, "Monday");
System.out.print("Enter no. of Passengers on Tuesday: ");
int not = sc.nextInt();
p.addFlights(not, "Tuesday");
System.out.print("Enter no. of Passengers on Wednesday: ");
int now = sc.nextInt();
p.addFlights(now, "Wednesday");
System.out.print("Enter no. of Passengers on Thursday: ");
int noth = sc.nextInt();
p.addFlights(noth, "Thursday");
System.out.print("Enter no. of Passengers on Friday: ");
int nof = sc.nextInt();
p.addFlights(nof, "Friday");
System.out.print("Enter no. of Passengers on Saturday: ");
int nosa = sc.nextInt();
p.addFlights(nosa, "Saturday");
planes.add(p);
System.out.print("Added a new Plane!\n");
} else if (choice.equalsIgnoreCase("r")) {
System.out.print("Enter name of plane to remove: ");
String remP = sc.next();
for (int i = 0; i < planes.size(); i++) {
if (planes.get(i).getName().equalsIgnoreCase(remP)) {
planes.remove(i);
System.out.print("Removed a Plane!\n");
}
}
} else if (choice.equalsIgnoreCase("s")) {
System.out.print("Enter num of Passengers: ");
int searchP = sc.nextInt();
ArrayList<Flight> f;
for (int i = 0; i < planes.size(); i++) {
f = planes.get(i).getFlights();
for (int j = 0; j < f.size(); j++) {
if (f.get(j).getNOP() == searchP) {
System.out.print("\nThe plane is: " + planes.get(i).getName());
System.out.print("\nThe day is: " + f.get(j).getDay());
}
}
}
}
}

}
}

arrow_forward





Plane.java

import java.util.*;

public class Plane {
int noOfSeats;
String name;
ArrayList<Flight> flights;

public Plane(int noOfSeats, String name) {
this.noOfSeats = noOfSeats;
this.name = name;
flights = new ArrayList<Flight>();
}

public void addFlights(int nop, String day) {
Flight f = new Flight(day, nop);
flights.add(f);
}

public String getName() {
return this.name;
}

public ArrayList<Flight> getFlights() {
return this.flights;
}
}

arrow_forward







Flight.java

public class Flight {
int noOfPassengers;
String day;

public Flight(String day, int noOfPassengers) {

this.noOfPassengers = noOfPassengers;

this.day = day;
}

public int getNOP() {
return noOfPassengers;
}

public String getDay() {
return day;
}
}

arrow_forward






reference:
(Insert, search, delete)
It is capable of:

  • accepting the number of passengers per day of the different planes owned by the company;
  • displaying the number of passengers per plane per flight and per week;
  • searching for which plane and which day in a week given the number of passengers;
  • adding a new plane
  • removing a plane
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education