10141 - Request for Proposal

All about problems in Volume 101. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
hasib824
New poster
Posts: 1
Joined: Sun Dec 04, 2016 7:49 pm

10141 - Request for Proposal

Post by hasib824 » Sun Dec 04, 2016 7:59 pm

Hello Everyone following is my Java code . Can you please tell me why I am getting Runtime error ?? I have tried several times . Thanks in advance
------------------------------------------------------------------------------------------------------------------------------------------

import java.util.*;
public class Main{

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
float n = 1;
int it = 1;
float p;
float compliance = -1.0F;
String selected = "";
float cprice = 0.0F;
while (n != 0) {
n = sc.nextInt();
p = sc.nextInt();
while (n != 0) {
sc.nextLine();

for (int i = 0; i < n; i++) {
sc.nextLine();
}
for (int i = 0; i < p; i++) {
String RFP = sc.nextLine();

float price = sc.nextFloat();
float requirement_met = sc.nextFloat();
float comp = requirement_met / n;
if (comp > compliance) {
compliance = comp;
selected = RFP;
cprice = price;
} else if (compliance == comp) {
if (price < cprice) {
compliance = comp;
selected = RFP;
cprice = price;
}
}
sc.nextLine();
for (int j = 0; j < requirement_met; j++) {
sc.nextLine();
}
}
System.out.println("RFP #" + (it++) + "\n" + selected + "\n");
}
}
}
}

Post Reply

Return to “Volume 101 (10100-10199)”

Who is online

Users browsing this forum: No registered users and 1 guest