Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

oxygen cylinder management program in java

/*
Oxygen Cylinders Management
You are the given a list of covid patients where paitent[i] is the required by the ith patient, and there are enough cylinders 
where each cylinder contains a limited amount of oxygen. 
Each cylinder can serve at most two patients at the same time, provided the array of the oxgen required by the patients and cylinder capacity.
*/


import java.util.Scanner;
public class Main{
     static int numOxygenCylinder(int[] oxyegen, int limit){
         int sum =0;
         for(int i : oxyegen){
            sum+=i;
         }
         if(sum%limit == 0) return sum/limit;
         else return (sum/limit)+1;
     }
     public static void main(String[] args){
         Scanner sc = new Scanner(System.in);
         int n = sc.nextInt();
         int limit = sc.nextInt();
         
         int[] oxygen = new int[n];
         for(int i=0; i<n; i++) oxygen[i] = sc.nextInt();
         System.out.println(numOxygenCylinder(oxygen, limit));
     }
}
Comment

PREVIOUS NEXT
Code Example
Java :: code for working clock in java eclipse 
Java :: java enum valueof() 
Java :: how to select multiple non-consecutive words on mac 
Java :: sort a list according to location 
Java :: java filewriter not working 
Java :: jbutton scroll list full width size 
Java :: skip list java 
Java :: how to find a specific character in a string using array 
Java :: media style dependency androidx 
Java :: spigot self cancelling task 
Java :: resources/android/xml/network_security_config.xml 
Java :: java static nested class 
Java :: java jackson optional 
Java :: split() String android 
Java :: android studio bring keyboard up 
Java :: ERROR: Failed to resolve: com.github.HaarigerHarald:android-youtubeExtractor:v1.7.0 
Java :: java minimize all windows 
Java :: java oop design patterns 
Java :: who was the mother of thomas elva edison 
Java :: add element to queue java 
Java :: Java Default Access Modifier creates error in package two by importing package one 
Java :: open application programelly android studio 
Java :: maximum valid parentheses 
Java :: password = sdf345 password.isalpha() java 
Java :: fail method java 
Java :: java 11 read file line by line 
Java :: how to add a note in java 
Java :: JAVA for-each Loop Sytnax 
Java :: jdk full form 
Java :: List of tuple to map + jpa 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =