highpeaksw / coding-assignments

14 stars 450 forks source link

How to send the assignment #2

Open Ay923 opened 4 years ago

Ran1504 commented 3 years ago

WhatsApp Video 2020-10-31 at 6.42.00 PM.zip

dict.txt

Balraj852 commented 3 years ago

import java.io.; import java.util.; class Item { String name; int price;

public Item(String name, int price) { this.name = name; this.price = price; }

public String toString() { return this.name + ": " + this.price; } }

public class Main { public static void main(String[] args) throws Exception { FileInputStream fis=new FileInputStream("input.txt");
Scanner sc=new Scanner(fis); int number_of_employees = Integer.parseInt(sc.nextLine().split(": ")[1]); sc.nextLine(); sc.nextLine(); sc.nextLine();

ArrayList<Item> goodies_items = new ArrayList<Item>();

while(sc.hasNextLine())  
{
  String current[] = sc.nextLine().split(": ");
  goodies_items.add(new Item(current[0], Integer.parseInt(current[1])));
}
sc.close();

Collections.sort(goodies_items, new Comparator<Item>(){
  public int compare(Item a, Item b) { 
    return a.price - b.price; 
  } 
});

int min_diff = goodies_items.get(goodies_items.size()-1).price;
int min_index = 0;
for(int i=0;i<goodies_items.size()-number_of_employees+1;i++) {
  int diff = goodies_items.get(number_of_employees+i-1).price-goodies_items.get(i).price;

  if(diff<=min_diff) {
    min_diff = diff;
    min_index = i;
  }
}

FileWriter fw = new FileWriter("output.txt");
fw.write("The goodies selected for distribution are:\n\n");
for(int i=min_index;i<min_index + number_of_employees; i++) {
  fw.write(goodies_items.get(i).toString() + "\n");
}

fw.write("\nAnd the difference between the chosen goodie with highest price and the lowest price is " + min_diff);
  fw.close();

} }

Balraj852 commented 3 years ago

.

Pooja63964 commented 3 years ago

https://github.com/Pooja63964/high

poojashaiva1112@gmail.com

Shrutha1807 commented 3 years ago

https://github.com/Shrutha1807/High-peak-Assignment/blob/main/Java%20code%20.webm shruthac1807@gmail.com

talankikoushik commented 3 years ago

https://github.com/talankikoushik/goodies @.***

On Sat, Jun 19, 2021, 6:48 PM Shrutha1807 @.***> wrote:

https://github.com/Shrutha1807/High-peak-Assignment/blob/main/Java%20code%20.webm @.***

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/highpeaksw/coding-assignment-Sep-2020/issues/2#issuecomment-864405311, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUFSTKXDORYHN54L7YYARXLTTSKITANCNFSM4SLSVDPQ .

YASHWANTHSAIREDDYPANTARANGAM commented 3 years ago

https://user-images.githubusercontent.com/86144316/122644887-1a523880-d135-11eb-8a79-ac3a9f26d12b.mp4

yashwanthsaireddy7@gmail.com

YASHWANTHSAIREDDYPANTARANGAM commented 3 years ago

https://github.com/highpeaksw/coding-assignment-Sep-2020/issues/2#issuecomment-864410640

On Sat, Jun 19, 2021 at 6:55 PM talankikoushik @.***> wrote:

https://github.com/talankikoushik/goodies @.***

On Sat, Jun 19, 2021, 6:48 PM Shrutha1807 @.***> wrote:

https://github.com/Shrutha1807/High-peak-Assignment/blob/main/Java%20code%20.webm @.***

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub < https://github.com/highpeaksw/coding-assignment-Sep-2020/issues/2#issuecomment-864405311 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AUFSTKXDORYHN54L7YYARXLTTSKITANCNFSM4SLSVDPQ

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/highpeaksw/coding-assignment-Sep-2020/issues/2#issuecomment-864406106, or unsubscribe https://github.com/notifications/unsubscribe-auth/AURHKPBSRIBALG75XZR74DDTTSLDTANCNFSM4SLSVDPQ .

talankikoushik commented 3 years ago

https://github.com/talankikoushik/goodies @.***

On Sat, Jun 19, 2021, 7:33 PM YASHWANTHSAIREDDYPANTARANGAM < @.***> wrote:

https://user-images.githubusercontent.com/86144316/122644887-1a523880-d135-11eb-8a79-ac3a9f26d12b.mp4

@.***

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/highpeaksw/coding-assignment-Sep-2020/issues/2#issuecomment-864410640, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUFSTKQU5YM4MOXGGPXXTH3TTSPSRANCNFSM4SLSVDPQ .

talankikoushik commented 3 years ago

https://github.com/talankikoushik/goodies @.***

On Sat, Jun 19, 2021, 7:34 PM Koushik Thalanki @.***> wrote:

https://github.com/talankikoushik/goodies @.***

On Sat, Jun 19, 2021, 7:33 PM YASHWANTHSAIREDDYPANTARANGAM < @.***> wrote:

https://user-images.githubusercontent.com/86144316/122644887-1a523880-d135-11eb-8a79-ac3a9f26d12b.mp4

@.***

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/highpeaksw/coding-assignment-Sep-2020/issues/2#issuecomment-864410640, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUFSTKQU5YM4MOXGGPXXTH3TTSPSRANCNFSM4SLSVDPQ .

Preeti199909 commented 3 years ago

HR Program.txt sample_input.txt

https://user-images.githubusercontent.com/86511185/123509726-ca272900-d694-11eb-9a3a-e09c7afc738a.mp4

LOHITHCHANDRASHEKAR commented 2 years ago

https://github.com/LOHITHCHANDRASHEKAR/LOHITHC-ASSIGNMENT