PLEASE NEED HELP WITH THIS JAVA CODE!!!!! I need help changing this java code from scanner input to ONLY JOptionPane for input and output. So meaning no import scanner should not be in this code only import JOptionPane should be in this code for input and output import java.util.Scanner; // class to perform all processing class Process { // method to get best bid from the 2D array public int getBestBid(int [][]bidsAndRatings) { int bestIndex=0; // Loop to check each element and determine which is the best bid of all for(int i=1;i<5;i++) { if(bidsAndRatings[i][0] < bidsAndRatings[bestIndex][0] && bidsAndRatings[i][1] > bidsAndRatings[bestIndex][1]) { bestIndex=i; } } // return the index of best bid from the array return bestIndex; } // method to print report of the bid public void printBids(int [][]bidsAndRatings,String []namesOfContacter) { // varaible to calculate total bids int totalBids = 0; // printing the report in well formatted format System.out.println("\nAll Bids placed are: "); System.out.printf("\n%10s %10s %10s\n","Name","Bid","Rating"); // Loop to print the report for(int i=0;i<5;i++) { System.out.printf("\n%10s %10d %10d",namesOfContacter[i],bidsAndRatings[i][0],bidsAndRatings[i][1]); totalBids+=bidsAndRatings[i][1]; } // printing average of bids System.out.println("\nAvergae Bid Amount is "+(totalBids/5)); } public void takeAndProcessInputs(int maxBudget) { // 2d array for bids and ratings and 1D array for names // 2D array has column 1 for bids and column 2 for ratings int [][] bidsAndRatings = new int[5][2]; String []namesOfContacter = new String[5]; Scanner cin = new Scanner(System.in); int inputsTaken = 0; // Loop to accept inputs until 5 inputs are recived while(inputsTaken!=5) { // take inputs from the user one by one System.out.println("\nEnter the details bid number "+(inputsTaken+1)); System.out.print("Enter the bid amount: "); int bid = cin.nextInt(); System.out.print("Enter the rating: "); int rating = cin.nextInt(); System.out.print("Enter the name of contractor: "); namesOfContacter[inputsTaken] = cin.next(); // If ratings and bid is valid then add it to array and increment inputtaken variable if(rating <= 5 && bid <= maxBudget) { bidsAndRatings[inputsTaken][0] = bid; bidsAndRatings[inputsTaken][1] = rating; inputsTaken++; } // if rating is invalid accept inputs again else if (rating > 5) { System.out.println("\nRating input is invalid!"); } // if bid is invalid accept inputs again else if(bid > maxBudget) { System.out.println("\nBid amount is more than max budget"); } } // get index of best bid int indexOfBestBid = getBestBid(bidsAndRatings); // print report of all bids printBids(bidsAndRatings,namesOfContacter); // print winning bid System.out.println("\n\nWinning bid : "); System.out.printf("\n%10s %10d %10d",namesOfContacter[indexOfBestBid],bidsAndRatings[indexOfBestBid][0],bidsAndRatings[indexOfBestBid][1]); } } // Main class with main function public class Main { public static void main(String[] args) { // Accept input for maximum budget Scanner cin = new Scanner(System.in); System.out.print("Enter the maximum budget: "); int maxBudget = cin.nextInt(); // create object of class and call the function Process p = new Process(); p.takeAndProcessInputs(maxBudget); } }

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 NEED HELP WITH THIS JAVA CODE!!!!! I need help changing this java code from scanner input to ONLY JOptionPane for input and output. So meaning no import scanner should not be in this code only import JOptionPane should be in this code for input and output import java.util.Scanner; // class to perform all processing class Process { // method to get best bid from the 2D array public int getBestBid(int [][]bidsAndRatings) { int bestIndex=0; // Loop to check each element and determine which is the best bid of all for(int i=1;i<5;i++) { if(bidsAndRatings[i][0] < bidsAndRatings[bestIndex][0] && bidsAndRatings[i][1] > bidsAndRatings[bestIndex][1]) { bestIndex=i; } } // return the index of best bid from the array return bestIndex; } // method to print report of the bid public void printBids(int [][]bidsAndRatings,String []namesOfContacter) { // varaible to calculate total bids int totalBids = 0; // printing the report in well formatted format System.out.println("\nAll Bids placed are: "); System.out.printf("\n%10s %10s %10s\n","Name","Bid","Rating"); // Loop to print the report for(int i=0;i<5;i++) { System.out.printf("\n%10s %10d %10d",namesOfContacter[i],bidsAndRatings[i][0],bidsAndRatings[i][1]); totalBids+=bidsAndRatings[i][1]; } // printing average of bids System.out.println("\nAvergae Bid Amount is "+(totalBids/5)); } public void takeAndProcessInputs(int maxBudget) { // 2d array for bids and ratings and 1D array for names // 2D array has column 1 for bids and column 2 for ratings int [][] bidsAndRatings = new int[5][2]; String []namesOfContacter = new String[5]; Scanner cin = new Scanner(System.in); int inputsTaken = 0; // Loop to accept inputs until 5 inputs are recived while(inputsTaken!=5) { // take inputs from the user one by one System.out.println("\nEnter the details bid number "+(inputsTaken+1)); System.out.print("Enter the bid amount: "); int bid = cin.nextInt(); System.out.print("Enter the rating: "); int rating = cin.nextInt(); System.out.print("Enter the name of contractor: "); namesOfContacter[inputsTaken] = cin.next(); // If ratings and bid is valid then add it to array and increment inputtaken variable if(rating <= 5 && bid <= maxBudget) { bidsAndRatings[inputsTaken][0] = bid; bidsAndRatings[inputsTaken][1] = rating; inputsTaken++; } // if rating is invalid accept inputs again else if (rating > 5) { System.out.println("\nRating input is invalid!"); } // if bid is invalid accept inputs again else if(bid > maxBudget) { System.out.println("\nBid amount is more than max budget"); } } // get index of best bid int indexOfBestBid = getBestBid(bidsAndRatings); // print report of all bids printBids(bidsAndRatings,namesOfContacter); // print winning bid System.out.println("\n\nWinning bid : "); System.out.printf("\n%10s %10d %10d",namesOfContacter[indexOfBestBid],bidsAndRatings[indexOfBestBid][0],bidsAndRatings[indexOfBestBid][1]); } } // Main class with main function public class Main { public static void main(String[] args) { // Accept input for maximum budget Scanner cin = new Scanner(System.in); System.out.print("Enter the maximum budget: "); int maxBudget = cin.nextInt(); // create object of class and call the function Process p = new Process(); p.takeAndProcessInputs(maxBudget); } }

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Array
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
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