Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use the MoveMessageDemo program shown in the class as an example. Create a GUI A

ID: 3569419 • Letter: U

Question

Use the MoveMessageDemo program shown in the class as an example. Create a GUI Application called MoveCircle.java that does the followings: . Display a filled circle of radius 50 in the panel . The user cari press the left-button of the mouse and drag the circle around inside the panel . The program looks something like this, where the circle Is initially at the center of the panel and can be dragged around with the mouse Use the Loa nCa Iculator program shown in the class as an example. Create a GUI Application called BmiCalculator.java that calculates the BMI (body mass index). The formula is wetght tn kgs BMI= . (height ?n meters)2 . The program takes the weight and the height as inputs from the user . The user enters the weight & the height info and clicks on the ?Compute BMI? button . The resulting BMI value gets displayed as shown below: NeiJht(kg5) 678 leIoIItCnl) 185 ?MI 1981 Co?mpu w SMI . NOTE: You can use the setEditable method of the BMI result TextField and set to false, so the user cannot type into this text field. It is only used to display the result. Add a ?Clear? button to the BmiCalculator program that does the followings: . When the user clicks on this button, all the TextF?elds are cleared . Use the same Actionlistener class and the same actionPerformed method as the one for the ?Compute BMI? button (i.e., detect the source of the event to decide which action to take) BU CaIcuIo, ______________J

Explanation / Answer

#include<stdio.h>

#include<conio.h>

#include<stdlib.h>

#define MAX 50

int size;

// Defining the stack structure

struct stack {

  int arr[MAX];

  int top;

};

// Initializing the stack(i.e., top=-1)

void init_stk(struct stack *st) {

  st->top = -1;

}

// Entering the elements into stack

void push(struct stack *st, int num) {

  if (st->top == size - 1) {

     printf(" Stack overflow(i.e., stack full).");

     return;

  }

  st->top++;

  st->arr[st->top] = num;

}

//Deleting an element from the stack.

int pop(struct stack *st) {

  int num;

  if (st->top == -1) {

     printf(" Stack underflow(i.e., stack empty).");

     return NULL;

  }

  num = st->arr[st->top];

  st->top--;

  return num;

}

void display(struct stack *st) {

  int i;

  for (i = st->top; i >= 0; i--)

     printf(" %d", st->arr[i]);

}

int main() {

  int element, opt, val;

  struct stack ptr;

  init_stk(&ptr);

  printf(" Enter Stack Size :");

  scanf("%d", &size);

  while (1) {

     printf(" tSTACK PRIMITIVE OPERATIONS");

     printf(" 1.PUSH");

     printf(" 2.POP");

     printf(" 3.DISPLAY");

     printf(" 4.QUIT");

     printf(" ");

     printf(" Enter your option : ");

     scanf("%d", &opt);

     switch (opt) {

     case 1:

       printf(" Enter the element into stack:");

       scanf("%d", &val);

       push(&ptr, val);

       break;

     case 2:

       element = pop(&ptr);

       printf(" The element popped from stack is : %d", element);

       break;

     case 3:

       printf(" The current stack elements are:");

       display(&ptr);

       break;

     case 4:

       exit(0);

     default:

       printf(" Enter correct option!Try again.");

     }

  }

  return (0);

}

#include<stdio.h>

#include<conio.h>

#include<stdlib.h>

#define MAX 50

int size;

// Defining the stack structure

struct stack {

  int arr[MAX];

  int top;

};

// Initializing the stack(i.e., top=-1)

void init_stk(struct stack *st) {

  st->top = -1;

}

// Entering the elements into stack

void push(struct stack *st, int num) {

  if (st->top == size - 1) {

     printf(" Stack overflow(i.e., stack full).");

     return;

  }

  st->top++;

  st->arr[st->top] = num;

}

//Deleting an element from the stack.

int pop(struct stack *st) {

  int num;

  if (st->top == -1) {

     printf(" Stack underflow(i.e., stack empty).");

     return NULL;

  }

  num = st->arr[st->top];

  st->top--;

  return num;

}

void display(struct stack *st) {

  int i;

  for (i = st->top; i >= 0; i--)

     printf(" %d", st->arr[i]);

}

int main() {

  int element, opt, val;

  struct stack ptr;

  init_stk(&ptr);

  printf(" Enter Stack Size :");

  scanf("%d", &size);

  while (1) {

     printf(" tSTACK PRIMITIVE OPERATIONS");

     printf(" 1.PUSH");

     printf(" 2.POP");

     printf(" 3.DISPLAY");

     printf(" 4.QUIT");

     printf(" ");

     printf(" Enter your option : ");

     scanf("%d", &opt);

     switch (opt) {

     case 1:

       printf(" Enter the element into stack:");

       scanf("%d", &val);

       push(&ptr, val);

       break;

     case 2:

       element = pop(&ptr);

       printf(" The element popped from stack is : %d", element);

       break;

     case 3:

       printf(" The current stack elements are:");

       display(&ptr);

       break;

     case 4:

       exit(0);

     default:

       printf(" Enter correct option!Try again.");

     }

  }

  return (0);

}