Looking for some help with this Java program I am totally lost on how to go about this.


The program is written in Java 8 using Eclipse IDE and MySQL for database
Program
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class SalesPerson {
public static void main(String[] args) throws
IOException, SQLException {
BufferedReader br = new
BufferedReader(new InputStreamReader(System.in));
int choice;
Connection con =
getConnection();
System.out.println("1. To add
record");
System.out.println("2. To delete
record");
System.out.println("3. To change
record");
System.out.print("Enter your
choice: ");
choice =
Integer.parseInt(br.readLine());
switch (choice) {
case 1:
toAdd(con,
br);
break;
case 2:
toDelete(con,
br);
break;
case 3:
toUpdate(con,
br);
break;
default:
System.out.println("Invalid Choice");
break;
}
}
//updating the database
private static void toUpdate(Connection con,
BufferedReader br)throws SQLException, IOException {
System.out.print("Enter ID:
");
int id =
Integer.parseInt(br.readLine());
Statement stmt =
con.createStatement();
ResultSet rs =
stmt.executeQuery("SELECT * FROM salesPerson where ID = " +
id);
if (rs.next() == true) {
System.out.print("Enter month 1: ");
double month1 =
Double.parseDouble(br.readLine());
System.out.print("Enter month 2: ");
double month2 =
Double.parseDouble(br.readLine());
System.out.print("Enter month 3: ");
double month3 =
Double.parseDouble(br.readLine());
stmt.executeUpdate("UPDATE salesPerson SET month1="+month1
+ ", month2 = "+month2
+ ", month3 = "+month3
+ "WHERE id="+id);
showResult(con);
}
else
System.out.println("ID does not exist in the database");
}
//deleteing data from the database
private static void toDelete(Connection con,
BufferedReader br) throws SQLException, IOException {
System.out.print("Enter ID:
");
int id =
Integer.parseInt(br.readLine());
Statement stmt =
con.createStatement();
ResultSet rs =
stmt.executeQuery("SELECT * FROM salesPerson where ID = " +
id);
if (rs.next() == true) {
stmt.executeUpdate("Delete From salesPerson Where id = "+id);
showResult(con);
}
else
System.out.println("ID does not exist in the database");
}
//inserting data to the database
private static void toAdd(Connection con,
BufferedReader br) throws SQLException, IOException {
System.out.print("Enter ID:
");
int id =
Integer.parseInt(br.readLine());
Statement stmt =
con.createStatement();
ResultSet rs =
stmt.executeQuery("SELECT * FROM salesPerson where ID = " +
id);
if (rs.next() == false) {
System.out.print("Enter month 1: ");
double month1 =
Double.parseDouble(br.readLine());
System.out.print("Enter month 2: ");
double month2 =
Double.parseDouble(br.readLine());
System.out.print("Enter month 3: ");
double month3 =
Double.parseDouble(br.readLine());
stmt.executeUpdate(
"Insert Into salesPerson
values (" + id + ", " + month1 + ", " + month2 + ", " + month3 +
")");
showResult(con);
}
else
System.out.println("ID exists in the database");
}
//fecthing data from the database
private static void showResult(Connection con) throws
SQLException {
System.out.println();
Statement stmt =
con.createStatement(); //for creating statement to fetch and
retrieve data from DB
ResultSet rs =
stmt.executeQuery("SELECT * FROM salesPerson");//resultset hold the
data
System.out.println("ID Month 1
Month 2 Month 3");
while(rs.next()) {
System.out.print(rs.getString("ID")+" ");//the column name to get
the value from that particular column
System.out.print(rs.getString("month1")+" ");
System.out.print(rs.getString("month2")+" ");
System.out.print(rs.getString("month3"));
System.out.println();
}
stmt.close();
}
//creating connection with the database
public static Connection getConnection() {
Connection con = null;
try {
Class.forName("com.mysql.cj.jdbc.Driver");// this is the name of
the mysql driver
// Database Driver, server
address, port no., database name,
// username, password
con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/javatest?autoReconnect=true&useSSL=false",
"root", "Aman@123");
// supress the
SSL error
System.out.println("Database Connected Successfully");
} catch (ClassNotFoundException e)
{
System.err.println("Load Falied: " + e);
} catch (SQLException e) {
System.err.println("Connection Falied: " + e);
}
return con;
}
}
Output

Looking for some help with this Java program I am totally lost on how to go about this. You have been approached by a local grocery store to write a program that will track the progress of their sale...
Hello. can anyone solve this. i am having hard time with this. please post a solution ASAP a) Create a class named Student. Data fields for Student class include an integer Student ID, a String name, and a double CGPA. Methods include a constructor that requires values for all data fields, as well as get and set methods for each of the data fields. b) Create an application that allows a user to enter values for an array of 15...
This program will store a roster of most popular videos with kittens. The roster can include at most 10 kittens.You will implement structures to handle kitten information. You will also use functions to manipulate the structure. (1) Create a structure kitten. The structure should contain the following attributes: name; string color; string score; integer Important! The name of the structure and each of its field must match exactly for the program to work and be graded correctly. (2) Create a...
write a c++ program :Assume one of the companies is renting flats for people asks you to develop a small system to help them track who paid the rent fees, and who did not for the coming month. The data in this system includes: ID number of the person who rented the house, flat number , fine to be paid, tenant name, status of payment(paid or unpaid ). The main interface of the system should be as follows: 1- Add...
(2 bookmarks) In JAVA You have been asked to write a program that can manage candidates for an upcoming election. This program needs to allow the user to enter candidates and then record votes as they come in and then calculate results and determine the winner. This program will have three classes: Candidate, Results and ElectionApp Candidate Class: This class records the information for each candidate that is running for office. Instance variables: first name last name office they are...
Here is everything I have on my codes, the compiler does not allow me to input my name, it will print out "Please enter your name: " but totally ignores it and does not allow me to input my name and just proceeds to my result of ID and Sale. Please help. I've bolded the part where it I should be able to input my name package salesperson; public class Salesperson { String Names; int ID; double Sales; // craeting...
Write a Java Program that performs the following functionalities: and you can use if statements, cases, and string methods Enter a new main sentence Find a String Find all incidents of a String Find and Replace a String Replace all the incidents of a String Count the number of words Count a letter’s occurrences Count the total number of letters Delete all the occurrences of a word Exit The program will display a menu with each option above, and then...
Implement a software program in C++ t stores and searches the Student records using double-hashing algorithm. Double hashing uses the idea of applying a second hash function to key when a collision occurs. The software program will be based on the following requirements: Development Environment: If the software program is written in C++, its project must be created using Microsoft Visual Studio 2017. If the software program is written in Java, its project must be created using NetBeans v8.2. Algorithm: If...
Can you help us!! Thank you!
C++
Write a program that can be used by a small theater to sell tickets for performances. The program should display a screen that shows which seats are available and which are taken. Here is a list of tasks this program must perform • The theater's auditorium has 15 rows, with 30 seats in each row. A two dimensional array can be used to represent the seats. The seats array can be initialized with...
Write a Java program which will store, manipulate, and print student registration information. As part of the solution, identify the following classes: Student Admissions. The class Student must have the following fields – Name, Address, Id number, Courses, and Date, where: Name is a user defined class comprising of at minimum first name and last name. Address is a user defined class comprising of fields - street, city, state, and zip code. Date is a predefined class in the java.util...
In C Program This program will store the roster and rating information for a soccer team. There will be 3 pieces of information about each player: Name: string, 1-100 characters (nickname or first name only, NO SPACES) Jersey Number: integer, 1-99 (these must be unique) Rating: double, 0.0-100.0 You must create a struct called "playData" to hold all the information defined above for a single player. You must use an array of your structs to to store this information. You...