Koti Syamala

Koti Syamala

Write a java program that simulates a traffic light. The program lets the user select one of three lights: red, yellow, or green. When a radio button is selected, the light is turned on, and only one light can be on at a time No light is on when the program starts.

//Program for implementing Traffic Signals import java.applet.*; import java.awt.*; import java.awt.event.*; /*<applet code=”Signals” width=400 height=250></applet>*/ public class Signals extends Applet implements ItemListener {             String msg=””;             Checkbox  stop,ready,go;             CheckboxGroup cbg;             public void init()             {                         cbg…

Write a Java program that correctly implements producer consumer problem using the concept of multithreading.

Java Design Patterns | Consumer and Producer Pic credit: Freepic.com // implementation of a producer and consumer. class Q {             int n;             boolean valueSet = false;             synchronized int get()              {                         while(!valueSet)                         try                         {…

Create a user defined exception in java

Java Custom Exceptions Program to create a user defined exception class Myexception extends Exception {             int detail;             Myexception(int a)             {                         detail=a;             }             public String toString()             {                         return “Myexception[“+detail+”]”;             } } class…

(Exception Handling and Multithreading) a) Write a program that reads two numbers from the user to perform integer division into Num1 and Num2 variables. The division of Num1 and Num2 is displayed if they are integers. If Num1 or Num2 were not an integer, the program would throw a NumberFormatException. If Num2 were Zero, the program would throw an ArithmeticException.

//Program to throw implement division and throw exceptions import java.util.*; class NAexception {             public static void main(String args[])             {                         Scanner scr=new Scanner(System.in);                         int num1,num2,q;                         try                         {                                     System.out.println(“nEnter the value of first integer :…

(packages) Design a package to contain the class Student that contains data members such as name, roll number and another package contains the interface Sports which contains some sports information. Import these two packages in a package called Report which process both Student and Sport and give the report.

package pack1; public class Student {                                                          public int rol_no=18;                         public char name[]={‘s’,’e’,’k’,’h’,’a’,’r’}; }                                     package pack2; public interface Sports {             void show();                                     }             //Program to implement packages package Record; import pack1.*; import pack2.*;…

Write a java program evaluates the postfix expression

//Evaluating the postfix expression import java.util.*; class postfix1 {             double a[]=new double[20];             int top;             postfix1() { top=-1; }                         void push(double x)             {                                  top++;                         a[top]=x;             }                         double pop()             {…

Write a java program Converts infix expression into Postfix form

//Program for infix to postfix conversion import java.util.*; class itop1 {             char s[]=new char[10];             int top;             itop1() {top=-1; }                         void i2post(char in[])             {                         int i,j=0;                         char post[]=new char[20];                         char ichar,schar;                        …

Write a Java program that Implements stack ADT.

//Program to implement Stacks import java.util.*; import java.io.*; class Stack1 {             int t;             int a[]=new int[5];             Stack1()             {                         t=-1;             }             boolean isempty()             {                         return (t==-1);             }             boolean isfull()            …

Write a Java program that Implements stack ADT.

//Program to implement Stacks import java.util.*; import java.io.*; class Stack1 {             int t;             int a[]=new int[5];             Stack1()             {                         t=-1;             }             boolean isempty()             {                         return (t==-1);             }             boolean isfull()            …

Enable Notifications OK No thanks