NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

{
public static void main(String[] args) throws IOException {
InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
BufferedReader in = new BufferedReader(reader);
String line;
//while ((line = in.readLine()) != null) {
//System.out.println(line);
//}
String line1 = in.readLine();
String src = in.readLine();
String des = in.readLine();
int n= line1.length();
List<String> source = new ArrayList<>();
List<String> dest = new ArrayList<>();
List<Double> rate = new ArrayList<>();
String[] items1 = line1.split(";");
for(int i =0;i<items1.length;i++)
{
String inputlist[]=items1[i].split(",");
source.add(inputlist[0]);
dest.add(inputlist[1]);
rate.add(Double.parseDouble(inputlist[2]));
}
for(int i =0;i<source.size();i++)
{
System.out.println(source.get(i)+" "+dest.get(i)+" "+rate.get(i));
}

// source.add("U");
// source.add("U");
// source.add("G");
// source.add("C");
// source.add("C");
// dest.add("G");
// dest.add("J");
// dest.add("J");
// dest.add("C");
// dest.add("K");
// rate.add(0.7);
// rate.add(109.0);
// rate.add(155.0);
// rate.add(5.27);
// rate.add(921.0);
double result = calculate(source, dest, rate,src,des);
System.out.println(result);
}

public static double calculate(List source, List dest, List rate, String src, String des){
double val = 1;
double maxval = 0;
String olddest = des;

for(int i = 0; i < dest.size(); i++){
System.out.println(dest.get(i)+" "+source.get(i));

if (dest.get(i).equals(des) && source.get(i).equals(src)){
System.out.println("Both are equal");
System.out.println("Curr Target: " + dest.get(i) + " Destination: " + des + " Curr Src: " + source.get(i) + " Source: " + src );
if (!(dest.get(i).equals(olddest))){
val = val * (double) rate.get(i);
maxval = Math.max(maxval, val);
}
else if(dest.get(i).equals(olddest)) {
maxval = Math.max(maxval, (double) rate.get(i));
}
} else if (dest.get(i).equals(des) && !source.get(i).equals(src)) {
System.out.println("First equal and second not equal");
System.out.println("Curr Target: " + dest.get(i) + " Destination: " + des + " Curr Src: " + source.get(i) + " Source: " + src );
val = val * (double) rate.get(i);
des = (String) source.get(i);
i = -1;
}
else if(!(dest.contains(olddest)))
{
maxval = -1.0;
}
}
return maxval;
}
}
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.