Tuesday, 16 February 2021

Zoho round 1 questions

 1. Find the output for the following programs(branching and looping)

#include<stdio.h>

Void main()

{

int i;

for( i = 1 ; i < 4 ; i++)

{

 switch(i)

 {

 case 1 : printf("%d" , i);break;

 case 2 : printf("%d" , i);break;

 case 3 : printf("%d" , i);break;

 }

}

switch(i)

{

 case 4 : printf("%d" , i);break;

}

}

Output : 1234

2. Find the output( operartor and expression)

void main()

{

char *s = "\12345s\n";

printf("%d" , sizeof(s));

}

Output : 4

3. Find the output( Funtions)

int main()

{

static int i = 3;

printf("%d" , i--);

return i>0 ? main() : 0 ;

}

Output : 321

4. Find the output(pointers)

int main()

{

char *s[]={ "dharmr'a","hewlett-packard","siemens","ibm"};

char **p;

p = s ;

printf("%s" ,++*p);

printf("%s",*p++); ;

printf("%s" ,++*p);

}

Output: harmr’aharmr’aewlett-packard

5. Find the output( dynamic memory)

#include<stdio.h>

#include<malloc.h>

#include<string.h>

int main()

{

int i;

char a[]="String";

char *p = "New String";

char *temp;

temp = malloc(strlen(p) + 1);

p = malloc( strlen(temp) + 1);

strcpy(p , temp);

printf("%s" , p);

}

Output : unpredictable string

6. Find the output(algorithm)

int main()

{

int n = 12 , res = 1;

while( n > 3)

{

 n -= 3;

 res *= 3;

}

printf("%d" , n*res);

}

Output : 81

7. Find the output(function)

void fun(int [][3]);

int main()

{

int a[3][3] = {9,8,7,6,5,4,3,2,1};

fun(a);

printf("%d\n" , a[2][1]);

}

void fun(int b[][3])

{

 ++b;

 b[1][1]=5;

}

Output : 5

8. Find the output(strings)

void main()

{

 int i , n;

 char x[5];

 strcpy( x , "Zoho");

 n = strlen(x);

 *x = *(x+(n-1));

 printf("%s" , x);

}

Output: ooho

9. Find the output(arrays)

void main()

{

 int c[]={5,4,3,4,5};

 int j , *q = c;

 for( j = 0 ; j<5 ; j++){

 printf("%d" , *c);

 ++q;

 }

}

Output:55555

10. Find the output(branching and looping)

void main()

{

 int i = 1;

 for(i =0 ; i= -1 ; i=1){

 printf("%d", i);

 if(i!= 1) break;

 }

}

Output: -1

11. Find the output(Arrays)

void main()

{

 int s[] = {1,0,5,0,10,0};

 int f[] = {2,4,6,8,10,12};

 int n = 6 , i = 0 , j = 0;

 for( j = 1 ; j < n ; j++)

 {

 if( s[j] >= f[i])

 {

 printf("%d" , i);

 i = j;

 }

 }

}

output : 02

12. Find the output(Functions)

void f(int *a , int m)

{

 int j = 0;

 for(j = 0 ; j < m ; j++)

 {

 *(a+j) = *(a+j) - 5;

 }

}

void main()

{

 int a[] = {'f' , 'g' , 'h' , 'i' , 'j'};

 int j = 0 ;

 f(a , 5);

 for(j = 0 ; j<= 4 ; j++)

 printf("%c\t" , a[j]);

}

Output:a b c d e

13. Find the output(branching and looping)

void main()

{

 int i=0, j=0 , sum=0;

 for(i= 1; i < 500 ; i*=3)

 for(j=0;j<i;j++)

 sum++;

 printf("%d",sum);

}

Output: 364

14. Find the output(branching and looping)

void main()

{

 int n;

 for(n = 6 ; n!= 1; n--)

 printf("%d" , n--);

}

Output: infinite loop

15. Find the output(arrays)

void main()

{

 int a[3][4] = {2,4,6,5,10,12,12,10,5,6,4,2};

 int i = 0 , j , k =99;

 while(i < 3)

 {

 for(j = 0 ; j < 4 ; j= j++)

 {

 if( a[i][j] < k)

 {

 k = a[i][j];

 }

 }

 i++;

 }

 printf("%d" , k);

}

Output : 2

16. Find the output( pointer)

void main()

{

char *x="Alice";

int i , n = strlen(x);

*x = x[n];

for(i=0; i<=n; i++)

{

printf("%s ", x); x++;

printf("\n", x);

}

return 0;

}

Output : runtime error

17. Find the output(structures and union)

struct value{

int bit1:1;

int bit3:4;

int bit4:4;

}bit;

int main()

{

printf("%d\n", sizeof(bit));

return 0;

}

Output : 4

18. Find the output(dynamic memory)

struct node

{

int data;

float d;

struct node *link;

};

int main()

{

struct node *p, *q;

p = (struct node *) malloc(sizeof(struct node));

q = (struct node *) malloc(sizeof(struct node));

printf("%d, %d\n", sizeof(p), sizeof(q));

return 0;

}

Output : 4 , 4

19. Find the output(structures and unions)

typedef union

{

 int a;

 char b[10];

 float c;

}Union;

int main()

{

 Union x , y = {100};

 x.a = 50;

 strcpy(x.b , "Hello");

 x.c = 21.50;

 printf("%d %s %f\n" , x.a , x.b , x.c);

 printf("%d %s %f" , y.a,y.b, y.c);

}

Output:1101791232 21.500000

100 d 0.000000

20. Find the output(structures and union)

struct point{

int x;

int y ;

};

struct point origin , *pp;

int main()

{

 pp = &origin;

 printf("origin is (%d %d)\n", (*pp).x , (*pp).y);

 printf("origin is (%d %d)" , pp->x , pp->y);

 return 0;

}

Output : origin is (0 0 )

origin is (0 0 )

21. Find the output(branching and looping)

void main()

{

int i = -1;

printf("i =%d +i = %d\n" , i , +1);

}

Output : i=-1 i=1

22. Find the output(datatypes)

void main()

{

char not;

not=12;

printf("%d",not);

}

Output : 12

23. Find the output(branching and looping)

#define FALSE -1

#define TRUE 1

#define NULL 0

void main()

{

if(NULL)

puts("NULL");

else if(FALSE)

puts("TRUE");

else

puts(" FALSE");

}

Output : TRUE

24. Find the output(operator and expressions)

void main()

{

 int k = 1;

 printf("%d==1 is"" %s" ,k, k == 1 ? "TRUE":"FALSE");

}

Output : 1==1 is TRUE

25. Find the output(file manipulation)

int main()

{

FILE *ptr;

char i;

ptr=fopen("demo.c","r");

while((i=fgetch(ptr))!=EOF)

printf("%c",i);

}

26. Find the output(branching and looping)

int main()

{

int t , i ;

for ( t=4;scanf("%d",&i)-t;printf("%d\n",i))

 printf("%d--",t--);

}

Output : loop runs 4 timess

27. Find the output(structures and unions)

struct emp{

int len;

char name[1];

};

int main()

{

char newname[] = "Rahul";

struct emp *p = (struct emp *) malloc(sizeof(struct emp) -1 + strlen(newname)+

1);

p->len = strlen(newname);

strcpy(p -> name, newname);

printf("%d %s\n", p->len, p->name); return 0;

}

Output : 5 Rahul

28. Find the output(algorithm)

int main() {

printf("%d %d %d %d\n",72,072,0x72,0X72);

return 0;

}

Output : 72 58 114 114

29. Find the output(operator and expression)

void main()

{

char ch;

int a;

float b;

printf("bytes occupied by ch=%d\n",sizeof(ch));

printf("bytes occupied by a=%d\n",sizeof(a));

printf("bytes occupied by b=%d\n",sizeof(b));

}

Output :

Bytes occupied by ch=1

Bytes occupied by a=4

Bytes occupied by b=4

30. Find the output(operator and expressions)

void main()

{

 printf("%d\n" , sizeof('7'));

 printf("%d\n" , sizeof(7));

 printf("%d\n" , sizeof(7.0));

}

Output: 4

4

8

31. Find the output(datatypes)

void main()

{

 char ch=291;

 printf("%d %d %c\n",2147483648,ch,ch);

 return 0;

}

Output : -2147483648 35 #

32. Find the output(datatypes)

void main()

{

 int g;

 g=300000*300000/300000;

 printf("g=%d\n",g);

}

Output : -647

33. Find the output(datatypes)

void main()

{

 float a;

a=4/2;

printf("%f %f\n",a,4/2);

}

Output : 2.000000 0.000000

34. Find the output(ooperator and expression)

void main()

{

 printf("%d\n",sizeof(4)/sizeof(2.0));

 printf("%d\n",sizeof(2.0)/sizeof(4));

}

Output : 0 2

35. Find the output(operator and expression)

void main()

{

 int x=10,y=5,p,q;

 p=x > 9;

 q=x>3&& y!=3;

 printf("p=%d q=%d \n",p,q);

}

Output : p = 1 q=1

Friday, 5 February 2021

Railway Reservation java ---simple Format

QUESTIONDevelop a Railway Reservation Application 

contains

1.AC coach

2.Non AC coach

3. Seater

each should contain 60 seats and 10 waiting list max allowed rest request should be cancelled. If a confirmed ticket is cancelled then waiting list should moved to confirm ticket.

you should have

1.Ticket Booking

2.Ticket Cancellation

3.Status Checking

ANSWER:

//here i had 4 class 1-main class 2-manager class in which all the operations takes place 3&4-passenger and booking declaration class 

//MAIN CLASS BookingSystem.java

package RailwayReservation;


import java.util.ArrayList;

import java.util.HashMap;

import java.util.Map.Entry;

import java.util.Scanner;


class BookingSystem {


public static BookingManager bookingManager=new BookingManager();

static Scanner scanner=new Scanner(System.in);

public static void main(String[] args) {

int choice;

do

{

System.out.println("Enter you choice \n1.Ticket Booking \n2. Ticket Cancellation\n3. Status checking \n4.exit");

choice=scanner.nextInt();

while(choice<=4)

{

switch(choice) {

case 1: getBookingDetails();

break;

case 2: cancelBooking();

break;

case 3: showStatus();

break;

case 4: System.out.println("Thank u!! Visit again");

break;

}

break;

}

}while(choice<=4);

}

private static void getBookingDetails() {

int count,select=1;

int coach,noOfTickets,age;

char from,to,gender;

String name,preferedBerth;

System.out.println("enter the 1.AC, 2.Non-Ac, 3.Seater");

do

{

coach=scanner.nextInt();

}while(coach>3);

count=bookingManager.checkAvailability(coach);

if(count<=70)

{

if(count<=60) {

System.out.println("from");

from=scanner.next().charAt(0);

System.out.println("To");

to=scanner.next().charAt(0);

System.out.println("enter how many tickets required ");

noOfTickets=scanner.nextInt();

scanner.nextLine();

if(count+noOfTickets>4)

{

System.out.println("Cannot book"+(count+noOfTickets-70)+"/n want to continue enter 1 ");

select=scanner.nextInt();

noOfTickets=count+noOfTickets-70;

}

if(select==1)

{

HashMap<Integer,Booking> bookedTickets=new HashMap<Integer,Booking>();

for(int i=0;i<noOfTickets;i++) {

//scanner.nextLine();

System.out.println("enter name");

name=scanner.nextLine();

System.out.println("enter age");

age=scanner.nextInt();

System.out.println("enter gender");

gender=scanner.next().charAt(0);

scanner.nextLine();

System.out.println("enter  preferedBerth");

preferedBerth=scanner.nextLine();

ArrayList<Booking> temp=bookingManager.bookTicket(from,to,coach,noOfTickets,name,age,gender,preferedBerth);


bookedTickets.put(i+1, temp.get(0));

}

for(Entry<Integer, Booking> temp:bookedTickets.entrySet()) {

System.out.println("Customer Id : "+temp.getValue().getCustId());

System.out.println("Status "+temp.getValue().getStatus());

}

}

}

}

}

private static void showStatus() {

int custId;

String status;

System.out.println("enter customer id");

custId=scanner.nextInt();

status=bookingManager.checkStatus(custId);

System.out.println("your ticket is"+status);

}

private static void cancelBooking() {

int custId,select;

boolean check=true;

int amount=0;

System.out.println("enter customer id");

custId=scanner.nextInt();

check=showDetails(custId);

if(check) {

System.out.println("Kindly confirm to proceed cancel by enter 1");

select=scanner.nextInt();

if(select==1)

{

bookingManager.cancelTicket(custId);

System.out.println("your ticket canncelled and 5%  "+(amount*5/100)+"  of the ticket price "+amount+"    non refunded");


}

else

{

System.out.println("Thank you! your ticket is not cancelled");

}

}

}

private static boolean showDetails(int custId) {

boolean s=true;

Passenger passenger=bookingManager.getCustomerDetails(custId);

if(passenger!=null)

{

System.out.println("Name  "+passenger.getName());

System.out.println("From  "+passenger.getFrom());

System.out.println("To   "+passenger.getTo());

System.out.println("Coach   "+passenger.getCoachReq());

if(passenger.getStatus().equals("Cancelled"))

{

System.out.println("your ticket is already cancelled");

s=false;

}

else

{

System.out.println("status     "+passenger.getStatus());

System.out.println("Kindly note that once you cancel 5% of your ticket charges are not returnable");

}

}

return s;

}

void showTotalBookedTickets()

{

HashMap<Integer,Passenger> passList=bookingManager.getPassengerDetails();

}


}

//Booking class Booking.java

package RailwayReservation;
class Booking {
private int bookingId;
private int custId;
private String berth;
private int charges;
private int coachType;
public int getCharges() {
return charges;
}
public void setCharges(int charges) {
this.charges = charges;
}
public Booking(int bookingId, int custId, int coachType,String berth, String status,int charges) {
super();
this.bookingId = bookingId;
this.custId = custId;
this.berth = berth;
this.status = status;
this.charges=charges;
this.coachType=coachType;
}
private String status;
public int getBookingId() {
return bookingId;
}
public int getCoachType() {
return coachType;
}
public void setCoachType(int coachType) {
this.coachType = coachType;
}
public void setBookingId(int bookingId) {
this.bookingId = bookingId;
}
public int getCustId() {
return custId;
}
public void setCustId(int custId) {
this.custId = custId;
}
public String getBerth() {
return berth;
}
public void setBerth(String berth) {
this.berth = berth;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}

}

//Passenger class

package RailwayReservation;

class Passenger {
int custId;
String name;
int age;
char gender;
String preferedBerth;
int  noOfTicketsReq;
int coachReq;
String status;
int ticketId;
char from;
char to;
public Passenger(int custId, String name,int age, char gender, String preferedBerth, int noOfTicketsReq, int coachReq,
String status, int ticketId, char from, char to) {
super();
this.custId = custId;
this.age = age;
this.gender = gender;
this.preferedBerth = preferedBerth;
this.noOfTicketsReq = noOfTicketsReq;
this.coachReq = coachReq;
this.status = status;
this.ticketId = ticketId;
this.from = from;
this.to = to;
this.name=name;
}

public char getFrom() {
return from;
}

public void setFrom(char from) {
this.from = from;
}

public char getTo() {
return to;
}

public void setTo(char to) {
this.to = to;
}

public int getCustId() {
return custId;
}
public void setCustId(int custId) {
this.custId = custId;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public char getGender() {
return gender;
}
public void setGender(char gender) {
this.gender = gender;
}
public String getPreferedBerth() {
return preferedBerth;
}
public void setPreferedBerth(String preferedBerth) {
this.preferedBerth = preferedBerth;
}
public int getNoOfTicketsReq() {
return noOfTicketsReq;
}
public void setNoOfTicketsReq(int noOfTicketsReq) {
this.noOfTicketsReq = noOfTicketsReq;
}
public int getCoachReq() {
return coachReq;
}
public void setCoachReq(int coachReq) {
this.coachReq = coachReq;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public int getTicketId() {
return ticketId;
}
public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public void setTicketId(int ticketId) {
this.ticketId = ticketId;
}

}

//Booking manager class


package RailwayReservation;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;

class BookingManager {

static int passId=1,bookIdBAC=1,bookIdBNAC=1,bookIdBS=1,bookIdWAC=1,bookIdWNAC=1,bookIdWS=1;
HashMap<Integer,Booking> bookedTicketsAC=new HashMap<Integer,Booking>();
HashMap<Integer,Booking> waitingTicketsAC=new HashMap<Integer,Booking>();
HashMap<Integer,Booking> bookedTicketsNonAC=new HashMap<Integer,Booking>();
HashMap<Integer,Booking> waitingTicketsNonAC=new HashMap<Integer,Booking>();
HashMap<Integer,Booking> bookedTicketsSeater=new HashMap<Integer,Booking>();
HashMap<Integer,Booking> waitingTicketsSeater=new HashMap<Integer,Booking>();
HashMap<Integer,Passenger> passengerDetails=new HashMap<Integer,Passenger>();

public HashMap<Integer, Passenger> getPassengerDetails() {
return passengerDetails;
}

public void setPassengerDetails(HashMap<Integer, Passenger> passengerDetails) {
this.passengerDetails = passengerDetails;
}

public HashMap<Integer, Booking> getBookedTicketsAC() {
return bookedTicketsAC;
}
public void setBookedTicketsAC(HashMap<Integer, Booking> bookedTickets) {
this.bookedTicketsAC = bookedTickets;
}

public int checkAvailability(int coachType) {
int val=0;
switch(coachType)
{
case 1: val=bookedTicketsAC.size()+waitingTicketsAC.size();
break;
case 2: val=bookedTicketsNonAC.size()+waitingTicketsNonAC.size();
break;
case 3: val=bookedTicketsSeater.size()+waitingTicketsSeater.size();
break;
}
return val;
}
public ArrayList<Booking> bookTicket(char from,char to,int coach, int noOfTickets, String name, int age, char gender, String preferedBerth) {
ArrayList<Booking> result=new ArrayList<Booking>();
char berth='l';
switch(coach)
{
case 1: 
if(bookedTicketsAC.size()<2)
{
if(age>=60)
{
berth='l';
}
Booking book=new Booking(bookIdBAC,passId,coach,"L","Confirmed",1000);
Passenger pass=new Passenger(passId,name,age,gender,preferedBerth,noOfTickets,coach,"confirmed",bookIdBAC,from,to);
result.add(book);
bookedTicketsAC.put(bookIdBAC, book);
passengerDetails.put(passId, pass);
bookIdBAC++;
//passId--;
}
else
{
Booking book=new Booking(bookIdWAC,passId,coach,"L","Waiting",1000);
result.add(book);
waitingTicketsAC.put(bookIdWAC, book);
Passenger pass=new Passenger(passId,name,age,gender,preferedBerth,noOfTickets,coach,"Waiting",bookIdWAC,from,to);
passengerDetails.put(passId, pass);
bookIdWAC++;

}
passId++;
break;
case 2:
if(bookedTicketsNonAC.size()<=2)
{
Booking book=new Booking(bookIdBNAC,passId,coach,"L","Confirmed",500);
Passenger pass=new Passenger(passId,name,age,gender,preferedBerth,noOfTickets,coach,"Confirmed",bookIdBNAC,from,to);
result.add(book);
bookedTicketsNonAC.put(bookIdBNAC, book);
passengerDetails.put(passId, pass);
bookIdBNAC++;
}
else
{
Booking book=new Booking(bookIdWNAC,passId,coach,"L","Waiting",500);
result.add(book);
waitingTicketsNonAC.put(bookIdWNAC++, book);
Passenger pass=new Passenger(passId,name,age,gender,preferedBerth,noOfTickets,coach,"Waiting",bookIdWNAC,from,to);
passengerDetails.put(passId, pass);
bookIdWNAC++;
}
passId++;
break;
case 3:
if(bookedTicketsSeater.size()<=60)
{
Booking book=new Booking(bookIdBS,passId,coach,"L","Confirmed",200);
Passenger pass=new Passenger(passId,name,age,gender,preferedBerth,noOfTickets,coach,"confirmed",bookIdBS,from,to);
result.add(book);
bookedTicketsNonAC.put(bookIdBS, book);
passengerDetails.put(passId, pass);
bookIdBS++;
}
else
{
Booking book=new Booking(bookIdWS,passId,coach,"L","Waiting",200);
result.add(book);
waitingTicketsNonAC.put(bookIdWS, book);
Passenger pass=new Passenger(passId,name,age,gender,preferedBerth,noOfTickets,coach,"Waiting",bookIdWS,from,to);
passengerDetails.put(passId, pass);
//passId++;
bookIdWS++;
}
passId++;
break;
}
return result;
// TODO Auto-generated method stub
}

public String checkStatus(int custId) {
String status="invalid id";
Passenger pass=passengerDetails.get(custId);
if(pass!=null)
{
status=pass.getStatus();
}
return status;
}

public Passenger getCustomerDetails(int custId) {
Passenger pass=passengerDetails.get(custId);
System.out.println(pass.getName());
return pass;
}

public int cancelTicket(int custId) {
Passenger pass=passengerDetails.get(custId);
int ticketId=pass.getTicketId();
String status=pass.getStatus();
int coach=pass.getCoachReq();
int amount=0;
if(status.equals("Waiting"))
{
switch(coach)
{
case 1: waitingTicketsAC.remove(ticketId);
amount=1000;
break;
case 2: waitingTicketsNonAC.remove(ticketId);
amount=500;
break;
case 3: waitingTicketsSeater.remove(ticketId);
amount=200;
break;
}
}
else
{
Booking book=null;
int key=0;
switch(coach)
{
case 1: bookedTicketsAC.remove(ticketId);
for(Entry<Integer, Booking> temp:waitingTicketsAC.entrySet())
{
book=temp.getValue();
book.setStatus("Confirmed");
int k=book.getCustId();
Passenger p=passengerDetails.get(k);
p.setStatus("confirmed");
key=temp.getKey();
break;
}
bookedTicketsAC.put(bookIdBAC,book);
bookIdBAC++;
waitingTicketsAC.remove(key);
amount=1000;
break;
case 2: bookedTicketsNonAC.remove(ticketId);
for(Entry<Integer, Booking> temp:waitingTicketsNonAC.entrySet())
{
book=temp.getValue();
book.setStatus("Confirmed");
int k=book.getCustId();
Passenger p=passengerDetails.get(k);
p.setStatus("confirmed");
key=temp.getKey();
break;
}
bookedTicketsAC.put(bookIdBNAC,book);
bookIdBNAC++;
waitingTicketsNonAC.remove(key);
amount=500;
break;
case 3:bookedTicketsSeater.remove(ticketId);
for(Entry<Integer, Booking> temp:waitingTicketsSeater.entrySet())
{
book=temp.getValue();
book.setStatus("Confirmed");
int k=book.getCustId();
Passenger p=passengerDetails.get(k);
p.setStatus("confirmed");
key=temp.getKey();
break;
}
bookedTicketsSeater.put(bookIdBS,book);
bookIdBS++;
amount=200;
waitingTicketsNonAC.remove(key);
break;
}
}
pass.setStatus("Cancelled");
return amount;
}


}

Note: for me they didn't asked about the seat arrangement so i didnt concentrate on it


Solve the string expression

QUESTION

Alphabets are inside () and the number -9<=0>=9 which is under{} solve the string according to the sample input output  

Input (z){-2}oho

Output ZZoho

Input ((X){2}(y){3}(z)){2}

Output xxyyyzxxyyyz

Input ((x){2}){0}

output -(nothing should print)


ANSWER

package Practice;


import java.util.*;


class Expressions {


public static void main(String[] args) {

// TODO Auto-generated method stub

String input,output="",temp="",check="";

Scanner scanner=new Scanner(System.in);

input=scanner.nextLine();

Stack <String> stack=new Stack<String>();

for(int i=0;i<input.length();i++)

{

if(input.charAt(i)=='(') {

stack.push("(");

}

else if(input.charAt(i)>='a'&&input.charAt(i)<='z')

{

check+=input.charAt(i);


if(!stack.empty()&&!stack.peek().equals("("))

{

check=stack.pop()+check;

}


stack.push(check);

check="";

}

else if(input.charAt(i)==')')

{

temp=stack.pop();

while(!stack.peek().equals("("))

{

temp=stack.pop()+temp;

}

stack.pop();

stack.push(temp);

}

else if(input.charAt(i)=='{') {

i++;

temp=stack.pop();

if(input.charAt(i)=='-')

{

temp=temp.toUpperCase();

i++;

}

String temp1=temp;

if((input.charAt(i)-48)==0)

temp="";

for(int j=1;j<input.charAt(i)-48;j++)

{

temp+=temp1;

}

i++;

if(input.charAt(i)=='}') {

stack.push(temp);

}

else

{

stack.push("invalid expression");

break;

}

}

}

temp="";

for(int j=0;j<stack.size();j++)

{

temp+=stack.get(j);

}

System.out.println(temp);

}


}