forked from nishitpanchal395/projecthactoberfest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStackOperation.java
More file actions
54 lines (50 loc) · 1.42 KB
/
Copy pathStackOperation.java
File metadata and controls
54 lines (50 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import java.util.*;
public class ShopMain
{
public static void main (String[] args) {
Scanner sc=new Scanner(System.in);
System.out.print("Enter the no. of users:");
int n=sc.nextInt();
System.out.println();
if(n>=1 && n<=1000)
{
int[] a=new int[n];
int temp=0;
while(temp<n)
{
System.out.print("Enter the credit points for user "+(temp+1)+":");
a[temp]=sc.nextInt();
if(a[temp]>=1 && a[temp]<=100)
{
temp++;
System.out.println();
}
else
{
break;
}
}
System.out.print("Enter the no. of users to serve: ");
int k=sc.nextInt();
if(k>=1 && k<n)
{
System.out.print("The unserved user's credit points are: ");
for(int i=(k);i<n;i++)
{
System.out.print(a[i]+" ");
}
}
else if(k==n)
{
System.out.println("0 users to serve");
}
else
{
System.out.println("Invalid no. of users");
}
}
else{
System.out.println("Invalid no. of users");
}
}
}