The document provides code snippets for various Java programs involving classes, objects, inheritance, packages, exceptions, threads, file handling, database operations, and servlets. It includes 22 sections that demonstrate concepts like class syntax, method overriding and overloading, communication between classes, abstract classes, packages, try-catch blocks, user threads, multiple threads, file input/output, database insertion and fetching, servlets for form submission and passing values between servlets.
The document discusses various object oriented programming concepts like classes, objects, inheritance, polymorphism, abstraction etc. It provides 14 examples demonstrating different OOP concepts like creating simple classes, using main method, method overloading, overriding, communication between classes using objects and inheritance, calculating area of shapes using classes, use of abstract classes etc. Each example includes the class definition and main method to instantiate objects and call methods.
The document contains code for multiple Java classes and programs related to GUI development and basic math/logic operations. It defines classes for creating calculator interfaces with buttons, text fields, and frames. It also includes classes demonstrating inheritance, abstract classes, exceptions, input/output, and basic math functions like addition, subtraction, and multiplication.
This document discusses the R debugger. It provides examples of using the browser(), debug(), and debugonce() functions to debug R code. The browser allows stepping through code line-by-line and examining variable values. debug() and debugonce() activate debugging for a function. Other debugging topics covered include traceback(), browserText(), and examining the coefficients of linear models.
This document discusses environments and scoping in R. It provides examples of how parent environments and parent frames work when calling functions. The key points are:
- The parent environment of a function is the environment in which the function is defined.
- The parent frame of a function is the environment from which the function was called.
- Variables in the parent environments and frames may be accessible depending on the context.
The document describes programs to implement various operations on singly linked lists including insertion, deletion, counting nodes, creating a list, traversing a list, and copying a list. It provides functions for insertion at the beginning, end, and before/after a given node. Deletion functions remove from the beginning, end, or by item value. Counting returns the total nodes or occurrences of a value. Traversal and copying print or duplicate the list.
This document contains C program code examples for various programming problems. It is divided into 5 weeks. Some of the programs included are: exchanging values between two variables with and without a temporary variable, finding the sum of digits of a positive integer, generating factors of numbers, calculating the factorial of a number, computing the sine function as a series, generating the Fibonacci sequence, reversing digits of an integer, converting decimal to binary, octal and hexadecimal, calculating terms of a series, and performing basic mathematical operations based on user input. The document provides the code and output for each problem.
The document contains source code for performing various matrix operations and array operations in C#. It includes code to add, subtract and multiply matrices, calculate the inverse of a matrix, reverse the order of elements in an array, find the biggest and smallest elements in an array, swap two arrays, and sort an array in ascending and descending order. The code takes user input, performs the specified operation on the input data, and displays the output.
The document contains 14 code snippets demonstrating various array operations and sorting algorithms in C/C++, including:
1) Inserting an element into an array
2) Deleting an element from an array
3) Traversing the elements of an array
4) Implementing bubble sort, selection sort, and insertion sort algorithms
5) Performing linear and binary searches on arrays
6) Pushing and popping elements from a stack
7) Inserting elements into a queue
8) Merging two arrays
9) Converting an infix notation expression to postfix notation
The document discusses various object oriented programming concepts like classes, objects, inheritance, polymorphism, abstraction etc. It provides 14 examples demonstrating different OOP concepts like creating simple classes, using main method, method overloading, overriding, communication between classes using objects and inheritance, calculating area of shapes using classes, use of abstract classes etc. Each example includes the class definition and main method to instantiate objects and call methods.
The document contains code for multiple Java classes and programs related to GUI development and basic math/logic operations. It defines classes for creating calculator interfaces with buttons, text fields, and frames. It also includes classes demonstrating inheritance, abstract classes, exceptions, input/output, and basic math functions like addition, subtraction, and multiplication.
This document discusses the R debugger. It provides examples of using the browser(), debug(), and debugonce() functions to debug R code. The browser allows stepping through code line-by-line and examining variable values. debug() and debugonce() activate debugging for a function. Other debugging topics covered include traceback(), browserText(), and examining the coefficients of linear models.
This document discusses environments and scoping in R. It provides examples of how parent environments and parent frames work when calling functions. The key points are:
- The parent environment of a function is the environment in which the function is defined.
- The parent frame of a function is the environment from which the function was called.
- Variables in the parent environments and frames may be accessible depending on the context.
The document describes programs to implement various operations on singly linked lists including insertion, deletion, counting nodes, creating a list, traversing a list, and copying a list. It provides functions for insertion at the beginning, end, and before/after a given node. Deletion functions remove from the beginning, end, or by item value. Counting returns the total nodes or occurrences of a value. Traversal and copying print or duplicate the list.
This document contains C program code examples for various programming problems. It is divided into 5 weeks. Some of the programs included are: exchanging values between two variables with and without a temporary variable, finding the sum of digits of a positive integer, generating factors of numbers, calculating the factorial of a number, computing the sine function as a series, generating the Fibonacci sequence, reversing digits of an integer, converting decimal to binary, octal and hexadecimal, calculating terms of a series, and performing basic mathematical operations based on user input. The document provides the code and output for each problem.
The document contains source code for performing various matrix operations and array operations in C#. It includes code to add, subtract and multiply matrices, calculate the inverse of a matrix, reverse the order of elements in an array, find the biggest and smallest elements in an array, swap two arrays, and sort an array in ascending and descending order. The code takes user input, performs the specified operation on the input data, and displays the output.
The document contains 14 code snippets demonstrating various array operations and sorting algorithms in C/C++, including:
1) Inserting an element into an array
2) Deleting an element from an array
3) Traversing the elements of an array
4) Implementing bubble sort, selection sort, and insertion sort algorithms
5) Performing linear and binary searches on arrays
6) Pushing and popping elements from a stack
7) Inserting elements into a queue
8) Merging two arrays
9) Converting an infix notation expression to postfix notation
1. The document contains 10 code snippets implementing various data structures and algorithms in C/C++ like linear search, binary search, merge sort, quick sort, selection sort, bubble sort, stack implementation using array, Fibonacci series using recursion, queue implementation using array, and binary search tree operations like insertion, deletion, display and traversal.
2. The codes include functions for searching an element, sorting arrays, implementing stacks and queues as well as common operations on binary search trees.
3. Main functions are included to accept user input, call the relevant functions and output the results of operations like searching, sorting or tree traversals.
1. The document contains details of Pranav Ghildiyal, a class XII student. It includes a table of contents listing 24 programs with page numbers.
2. The programs cover concepts like arrays, structures, classes, inheritance, file handling, stacks, queues and more. Algorithms covered include sorting, searching and linked lists.
3. The document serves as an index for various C++ programs written by the student to demonstrate different concepts and data structures.
This document contains 17 programming problems and their solutions involving object oriented programming concepts like classes, objects, functions, arrays, pointers etc. The problems cover basic concepts like calculating factorial, checking prime number, Fibonacci series, arithmetic operations using menus. More advanced concepts covered include sorting, searching, function overloading, complex numbers, class/object concepts like constructors, destructors and member functions to maintain student records.
This document discusses binary search trees and provides source code to implement binary search tree traversal operations. It explains that a binary search tree is a binary tree where the left child of a node is less than the parent and the right child is greater. It provides code for preorder, inorder, and postorder traversals of the binary search tree and outputs the traversal order for a sample tree.
In the early days of computer science coding was viewed as an art. In the modern world of software engineering we may have lost the art to make way for rules and best practices. The International Obfuscated C Code Contest offers a chance for the coder to think beyond the rules of software engineering and unleash their creative side. We'll explore some of the more interesting entries in the past, take a closer look at some exotic C syntax, and finish up by exploring Bruce Holloway's 1986 entry.
From the Un-Distinguished Lecture Series (http://ws.cs.ubc.ca/~udls/). The talk was given Feb. 2, 2007
The document contains programs for various sorting and searching algorithms like insertion sort, selection sort, bubble sort, linear search, binary search, etc. It also includes programs for stack operations, queue operations, tower of Hanoi, infix to postfix conversion and postfix evaluation. Each program is written in C language and contains the main logic/code to implement the given algorithm or data structure operation.
The document contains examples demonstrating various object-oriented programming concepts in C++ including constructors, destructors, inheritance, polymorphism, operator overloading, templates, and more. Each example includes the code for a concept, the output of running the code, and a brief description.
The document contains 10 programs related to sorting and graph algorithms. Program 1-7 implement different sorting algorithms - insertion sort, selection sort, heap sort, quick sort, counting sort, merge sort and radix sort. Program 8 implements the greedy knapsack problem. Program 9 implements the travelling salesman problem. Program 10 implements Kruskal's algorithm to find the minimum spanning tree of a graph.
The document contains code snippets and descriptions for various C++ programs, including:
1) An abstract class example with Shape as the base class and Rectangle and Triangle as derived classes, demonstrating polymorphism.
2) A program that counts the words in a text by getting user input and parsing for whitespace.
3) An Armstrong number checker that determines if a number is an Armstrong number based on the sum of its digits.
4) Various other examples like binary search, complex number arithmetic, stacks, inheritance, and converting between Celsius and Fahrenheit temperatures.
This document describes a menu driven C program that implements operations on a circular linked list. The main menu allows the user to perform operations like create, display, insert, delete, count, sort, and reverse the circular linked list. Functions are defined to implement each operation - such as the create() function allocates a new node, the display() function prints the list, and insert functions add a node to the beginning, middle or end of the list.
The Ring programming language version 1.5.3 book - Part 10 of 184Mahmoud Samir Fayed
This document summarizes the key features and changes in Ring 1.5.3, including:
- The trace library allows tracing function calls and opening an interactive debugger. An example uses a breakpoint.
- The type hints library allows adding type information to improve code editors and static analysis. It supports user-defined types.
- Overall the documentation and quality of Ring 1.5 has improved based on real-world usage.
The program takes input of the order of a square matrix and its elements. It prints the elements of the matrix. It then calculates the trace of the matrix by adding the elements along the principal diagonal and prints the trace. The matrix elements are freed at the end.
The document discusses new features in C# 8 including readonly members, default interface methods, pattern matching with switch expressions and property patterns, using declarations, static local functions, asynchronous streams with IAsyncEnumerable, and null-coalescing assignment. Some key features covered are readonly members to prevent modification of struct fields and methods, default interface methods to provide implementation in interfaces, switch expressions as a cleaner alternative to switch statements, and property patterns for matching on property values in a switch expression.
This document discusses metaprogramming in C++ and describes an RPC framework implemented using C++ templates and metaprogramming. It defines an interface called calc_interface for a calculator RPC with functions like add and signals like expr_evaluated. It shows how to define the interface using meta_functions, and how a client can invoke functions on the server while handling serialization, transport, and response deserialization. Key aspects covered include defining the interface, invoking functions from the client, argument checking, and verifying functions exist in the interface.
This document describes a menu-driven C program that implements a doubly linked list. The program allows the user to perform operations like creation, insertion, deletion, sorting, and searching of nodes in the doubly linked list. The main functions include create() to create nodes, display() to print the list, insert() to add nodes at different positions, delete() to remove nodes, sort() to sort the list, and find() to search for a node. The program uses a menu to allow the user to select the desired operation on the doubly linked list.
Gary Bernhardt’s famous WAT talk pokes fun at the weird things in Ruby and JavaScript due to weak typing and operator overloading. But Go can be strange, too. It has its own odd behaviors, some of which we run into every day. Learning about Go’s corner cases teaches us how Go works under the covers.
The Ring programming language version 1.5.4 book - Part 10 of 185Mahmoud Samir Fayed
This document summarizes the key features and changes in Ring 1.5.2, including updates to the documentation, Ring Notepad, Form Designer, and sample applications. It provides code examples demonstrating new capabilities in the trace library, type hints library, OpenGL graphics, and event handling.
This document contains laboratory experiments on advanced Java programming concepts implemented using Java Server Pages (JSP) and Servlets. The experiments cover printing "Hello World", displaying system date and time, calculating factorials, addition of two numbers, simple interest calculation, solving quadratic equations, income tax calculation, and checking for prime numbers. Code snippets are provided for each experiment to accept user input, perform the given task on the server-side, and return output to the client. The directory structure and deployment details of sample JSP/Servlet programs are also included.
This document contains 22 code programs submitted by Ankit Dixit to his instructor Ms. Achhardeep Kaur for her class. The programs demonstrate various C++ concepts like conditional statements, loops, functions, arrays, pointers, structures, classes and objects. Example programs include checking if a number is even or odd, finding the greatest of three numbers, generating the Fibonacci series, and calculating the area of a rectangle using a class.
The document provides an index and descriptions of various topics related to web development including:
1. The modulus operator and examples of using it to check for divisibility.
2. Relational and logical operators like greater than, less than, equal to and examples of using them in code.
3. Descriptions of do-while and for loops with examples.
4. An example using a parameterized constructor to initialize cube dimensions.
5. Examples of string methods like startsWith, length, and trim.
6. Descriptions and examples of overloading methods and constructors.
7. An example of inheritance with overriding methods.
8. An interface example with animal classes
The document describes an example Java program that defines classes for a banking application including accounts, customers, and transactions. Key points:
1) It defines interfaces for interest rates and transactions that account classes can implement.
2) An abstract Account class and concrete SBAccount class that extends Account are defined.
3) A Customer class holds an SBAccount and allows transactions like deposit, withdraw, interest calculation.
4) A BankDemo class demonstrates creating a customer and performing sample transactions.
1. The document contains 10 code snippets implementing various data structures and algorithms in C/C++ like linear search, binary search, merge sort, quick sort, selection sort, bubble sort, stack implementation using array, Fibonacci series using recursion, queue implementation using array, and binary search tree operations like insertion, deletion, display and traversal.
2. The codes include functions for searching an element, sorting arrays, implementing stacks and queues as well as common operations on binary search trees.
3. Main functions are included to accept user input, call the relevant functions and output the results of operations like searching, sorting or tree traversals.
1. The document contains details of Pranav Ghildiyal, a class XII student. It includes a table of contents listing 24 programs with page numbers.
2. The programs cover concepts like arrays, structures, classes, inheritance, file handling, stacks, queues and more. Algorithms covered include sorting, searching and linked lists.
3. The document serves as an index for various C++ programs written by the student to demonstrate different concepts and data structures.
This document contains 17 programming problems and their solutions involving object oriented programming concepts like classes, objects, functions, arrays, pointers etc. The problems cover basic concepts like calculating factorial, checking prime number, Fibonacci series, arithmetic operations using menus. More advanced concepts covered include sorting, searching, function overloading, complex numbers, class/object concepts like constructors, destructors and member functions to maintain student records.
This document discusses binary search trees and provides source code to implement binary search tree traversal operations. It explains that a binary search tree is a binary tree where the left child of a node is less than the parent and the right child is greater. It provides code for preorder, inorder, and postorder traversals of the binary search tree and outputs the traversal order for a sample tree.
In the early days of computer science coding was viewed as an art. In the modern world of software engineering we may have lost the art to make way for rules and best practices. The International Obfuscated C Code Contest offers a chance for the coder to think beyond the rules of software engineering and unleash their creative side. We'll explore some of the more interesting entries in the past, take a closer look at some exotic C syntax, and finish up by exploring Bruce Holloway's 1986 entry.
From the Un-Distinguished Lecture Series (http://ws.cs.ubc.ca/~udls/). The talk was given Feb. 2, 2007
The document contains programs for various sorting and searching algorithms like insertion sort, selection sort, bubble sort, linear search, binary search, etc. It also includes programs for stack operations, queue operations, tower of Hanoi, infix to postfix conversion and postfix evaluation. Each program is written in C language and contains the main logic/code to implement the given algorithm or data structure operation.
The document contains examples demonstrating various object-oriented programming concepts in C++ including constructors, destructors, inheritance, polymorphism, operator overloading, templates, and more. Each example includes the code for a concept, the output of running the code, and a brief description.
The document contains 10 programs related to sorting and graph algorithms. Program 1-7 implement different sorting algorithms - insertion sort, selection sort, heap sort, quick sort, counting sort, merge sort and radix sort. Program 8 implements the greedy knapsack problem. Program 9 implements the travelling salesman problem. Program 10 implements Kruskal's algorithm to find the minimum spanning tree of a graph.
The document contains code snippets and descriptions for various C++ programs, including:
1) An abstract class example with Shape as the base class and Rectangle and Triangle as derived classes, demonstrating polymorphism.
2) A program that counts the words in a text by getting user input and parsing for whitespace.
3) An Armstrong number checker that determines if a number is an Armstrong number based on the sum of its digits.
4) Various other examples like binary search, complex number arithmetic, stacks, inheritance, and converting between Celsius and Fahrenheit temperatures.
This document describes a menu driven C program that implements operations on a circular linked list. The main menu allows the user to perform operations like create, display, insert, delete, count, sort, and reverse the circular linked list. Functions are defined to implement each operation - such as the create() function allocates a new node, the display() function prints the list, and insert functions add a node to the beginning, middle or end of the list.
The Ring programming language version 1.5.3 book - Part 10 of 184Mahmoud Samir Fayed
This document summarizes the key features and changes in Ring 1.5.3, including:
- The trace library allows tracing function calls and opening an interactive debugger. An example uses a breakpoint.
- The type hints library allows adding type information to improve code editors and static analysis. It supports user-defined types.
- Overall the documentation and quality of Ring 1.5 has improved based on real-world usage.
The program takes input of the order of a square matrix and its elements. It prints the elements of the matrix. It then calculates the trace of the matrix by adding the elements along the principal diagonal and prints the trace. The matrix elements are freed at the end.
The document discusses new features in C# 8 including readonly members, default interface methods, pattern matching with switch expressions and property patterns, using declarations, static local functions, asynchronous streams with IAsyncEnumerable, and null-coalescing assignment. Some key features covered are readonly members to prevent modification of struct fields and methods, default interface methods to provide implementation in interfaces, switch expressions as a cleaner alternative to switch statements, and property patterns for matching on property values in a switch expression.
This document discusses metaprogramming in C++ and describes an RPC framework implemented using C++ templates and metaprogramming. It defines an interface called calc_interface for a calculator RPC with functions like add and signals like expr_evaluated. It shows how to define the interface using meta_functions, and how a client can invoke functions on the server while handling serialization, transport, and response deserialization. Key aspects covered include defining the interface, invoking functions from the client, argument checking, and verifying functions exist in the interface.
This document describes a menu-driven C program that implements a doubly linked list. The program allows the user to perform operations like creation, insertion, deletion, sorting, and searching of nodes in the doubly linked list. The main functions include create() to create nodes, display() to print the list, insert() to add nodes at different positions, delete() to remove nodes, sort() to sort the list, and find() to search for a node. The program uses a menu to allow the user to select the desired operation on the doubly linked list.
Gary Bernhardt’s famous WAT talk pokes fun at the weird things in Ruby and JavaScript due to weak typing and operator overloading. But Go can be strange, too. It has its own odd behaviors, some of which we run into every day. Learning about Go’s corner cases teaches us how Go works under the covers.
The Ring programming language version 1.5.4 book - Part 10 of 185Mahmoud Samir Fayed
This document summarizes the key features and changes in Ring 1.5.2, including updates to the documentation, Ring Notepad, Form Designer, and sample applications. It provides code examples demonstrating new capabilities in the trace library, type hints library, OpenGL graphics, and event handling.
This document contains laboratory experiments on advanced Java programming concepts implemented using Java Server Pages (JSP) and Servlets. The experiments cover printing "Hello World", displaying system date and time, calculating factorials, addition of two numbers, simple interest calculation, solving quadratic equations, income tax calculation, and checking for prime numbers. Code snippets are provided for each experiment to accept user input, perform the given task on the server-side, and return output to the client. The directory structure and deployment details of sample JSP/Servlet programs are also included.
This document contains 22 code programs submitted by Ankit Dixit to his instructor Ms. Achhardeep Kaur for her class. The programs demonstrate various C++ concepts like conditional statements, loops, functions, arrays, pointers, structures, classes and objects. Example programs include checking if a number is even or odd, finding the greatest of three numbers, generating the Fibonacci series, and calculating the area of a rectangle using a class.
The document provides an index and descriptions of various topics related to web development including:
1. The modulus operator and examples of using it to check for divisibility.
2. Relational and logical operators like greater than, less than, equal to and examples of using them in code.
3. Descriptions of do-while and for loops with examples.
4. An example using a parameterized constructor to initialize cube dimensions.
5. Examples of string methods like startsWith, length, and trim.
6. Descriptions and examples of overloading methods and constructors.
7. An example of inheritance with overriding methods.
8. An interface example with animal classes
The document describes an example Java program that defines classes for a banking application including accounts, customers, and transactions. Key points:
1) It defines interfaces for interest rates and transactions that account classes can implement.
2) An abstract Account class and concrete SBAccount class that extends Account are defined.
3) A Customer class holds an SBAccount and allows transactions like deposit, withdraw, interest calculation.
4) A BankDemo class demonstrates creating a customer and performing sample transactions.
The document contains code snippets demonstrating various Java programming concepts:
1. It includes code examples to demonstrate bitwise operators, arithmetic operators, conditional operators, constructor overloading, and method overloading in Java.
2. Further code examples showcase prefix/postfix increment/decrement operators, relational operators, the super keyword, and pattern printing in Java.
3. The document also contains code for applets demonstrating buttons, checkboxes, choice lists, labels, lists, banner movement, graphics, and text fields.
4. Additional code shows examples of multithreading, the Scanner class, and text fields and buttons in Swing.
The document provides a collection of code snippets that implement different
The document contains 17 code snippets that demonstrate various Java programming concepts like loops, arrays, methods, classes, input/output, etc. Specifically, the code snippets show:
1. Using for loops to print numeric series
2. Accepting user input of different data types using Scanner and parsing
3. Using StringTokenizer and Scanner classes
4. Finding largest number among 3 inputs and printing tables
5. Demonstrating 2D arrays, array of objects, and command line arguments
6. Various String class methods like length(), substring(), indexOf() etc.
The document contains 21 programming problems involving Java concepts like arrays, loops, methods, classes, objects, constructors, and more. For each problem, source code is provided to demonstrate how to solve the problem, followed by sample output. Some key problems include: (1) printing series using nested loops, (2) receiving user input of different data types, (3) using StringTokenizer and Scanner classes, (4) finding largest of 3 numbers, (5) using 2D arrays and array of objects.
This document contains 22 Java code examples submitted by a student named Shazia from Quaid-e-Awam University of Engineering, Science & Technology in Nawabshah, Pakistan. The code examples cover basic Java programming concepts like arithmetic operations, if/else conditional statements, loops, methods to find largest numbers, prime numbers, factorials, reversing integers, and generating random numbers. Each code example is labeled and includes the full Java code and output when run.
The document contains code snippets for various Java programs that perform tasks like calculating the area of a circle, finding the factorial of a number, displaying prime numbers, sorting an array, counting characters in a string, reversing a string, creating and running threads, handling exceptions, and creating a simple applet with buttons to change the background color. The code examples demonstrate basic Java programming concepts like classes, methods, loops, arrays, exceptions, threads, applets, and event handling.
The document contains code snippets from 3 weekly coding assignments:
1) A Java program to check if a string is a palindrome. It compares characters at the beginning and end of the string.
2) A Java program to sort a list of names in ascending order using string comparison and swapping.
3) A Java program to count the frequency of words in a given text by tokenizing, sorting, and printing the words.
This document contains the details of a computer science project completed by Tirthanu Ghosh of class 12A. The project contains 30 programs on different topics written in the Java programming language using BlueJ. It includes programs to generate Pascal's triangle, display numbers in words, calculate an arithmetic progression series and sum, display a calendar for a given month and year, calculate factorials and Fibonacci series using recursion, and more. The document contains the algorithms, code solutions, variable descriptions and outputs for each program. It ends with acknowledgements from Tirthanu thanking those who helped with the project.
This document provides a manual for a Java and J2EE lab for 5th semester computer science students. It contains 15 programs covering topics like enums, annotations, collections, strings, servlets, and database connectivity. Each program is explained and the expected output is provided. The programs demonstrate core Java concepts and commonly used APIs for collections, strings, I/O, and database access.
java slip for bachelors of business administration.pdfkokah57440
The document contains code snippets from multiple Java programs. The code covers topics like:
- Printing characters from A-Z and a-z using for loops
- Copying content from one file to another while filtering non-alphabetic characters
- Finding the number of vowels in a user-input string
- Creating a GUI program to track mouse click and movement coordinates
- Checking if a number is an Armstrong number
- Calculating the area and volume of geometric shapes like cone and cylinder based on user input
- Creating patterns using nested for loops
- Deleting text files and getting file details from command line arguments
- Handling exceptions for divide by zero
- Transposing a matrix by swapping row and column
I dont know what is wrong with this roulette program I cant seem.pdfarchanaemporium
I don\'t know what is wrong with this roulette program I can\'t seem to get it to run.
Game Class:
public class Game {
public static void main(String[] args) {
Table table = new Table();
BinBuilder bb = new BinBuilder();
Outcome black = new Outcome(\"Black\", 35);
Bet bet = new Bet(10, black);
table.placeBet(bet);
Bin bin = bb.wheel.get(8);
System.out.println(bin.toString());
System.out.println(table.bets.toString());
System.out.println(black.toString());
ListIterator i = table.bets.listIterator();
Iterator b = bin.outcomes.iterator();
while(i.hasNext()) {
System.out.println(i.next().outcome.name.toString());
while(b.hasNext()){
System.out.println(b.next().name.toString());
if(i.next().outcome.equals(b.next())){
System.out.println(\"Win!\");
}
else{
System.out.println(\"Win :/\");
}
}
}
}
}
Player Class
public class Player {
public Table table;
public Outcome black;
public Bet bet;
public Player(Table table) {
table = new Table();
black = new Outcome(\"Black\", 1);
}
void placeBets() {
Bet bet = new Bet(100, black);
table.placeBet(bet);
}
void win(Bet bet) {
System.out.println(\"You\'ve won: \" + bet.winAmount());
}
void lose(Bet bet) {
System.out.println(\"You lost!\" + bet.loseAmount() + \":/\");
}
}
Outcome class
public class Outcome implements Comparable {
public String name;
public int odds;
public Outcome(String name, int odds){
this.name = name;
this.odds = odds;
}
public int winAmount(int amount){
return amount*this.odds;
}
public boolean equals(Outcome other){
return (this.name.equals(other.name));
}
public String toString() {
Object[] values= { name, new Integer(odds) };
String msgTempl= \"{0} ({1}:1)\";
return MessageFormat.format( msgTempl, values );
}
@Override
public int compareTo(E arg0) {
if(this.equals(arg0)){
return 0;
}
return 1;
}
}
Table Class
public class Table {
public int limit = 1000;
public LinkedList bets;
public Table() {
bets = new LinkedList();
}
public boolean isValid(Bet bet) {
int sum = 0;
for(Bet bett: bets) {
sum += bett.amountBet;
}
return (sum>limit);
}
public void placeBet(Bet bet) {
bets.add(bet);
}
ListIterator iterator() {
return bets.listIterator();
}
}
Wheel Class
public class Wheel extends TreeSet {
Vector bins;
NonRandom rng;
Set all_outcomes;
Wheel(NonRandom rng){
this.rng = rng;
rng = new NonRandom();
all_outcomes = new TreeSet();
bins = new Vector(38);
for (int i=0; i<38; i++){
bins.add(i, new Bin());
}
}
Bin next(){
int rand = rng.next(38);
return bins.elementAt(rand);
}
Bin get(int bin){
return bins.elementAt(bin);
}
public Outcome getOutcome( String name ){
TreeSet result= new TreeSet();
for( Iterator i = all_outcomes.iterator(); i.hasNext(); ) {
Outcome oc= i.next();
if( oc.name.contains(name) ) {result.add( oc );}
}
return result.first();
}
public void addOutcome(int bin, Outcome outcome) {
all_outcomes.add(outcome);
this.bins.elementAt(bin).add(outcome);
}
}
Bet Class
public class Bet {
public int amountBet;
public Outcome outcome;
public Bet(int amount, Outcome outcome) {
this.outcome = o.
The document contains 4 code snippets demonstrating different ways to take input in Java programs:
1) Using command line arguments and the args array to print a greeting with a passed in name
2) Swapping two integers entered from the keyboard using only two variables
3) Reading input from the keyboard using InputStreamReader and BufferedReader classes
4) Taking input using the Scanner class to read an integer, string, and double from console input
The document discusses various Java operators including assignment, arithmetic, relational, logical, bitwise, and shift operators. It provides examples of using each operator type on primitive data types like int and boolean. Key points include:
- Assignment (=), arithmetic (+ - * / %), relational (>, <, ==, !=), logical (&&, ||, !) and bitwise (& | ^ ~) operators in Java.
- Implicit type promotions and casts that occur with arithmetic and relational operators.
- Short-circuit evaluation behavior of logical && and || operators.
- Using shift operators (<< >> >>>) to manipulate bits in binary representations of integers.
The document discusses passing objects to methods in Java. It defines a Block class with dimensions and volume that can be passed to methods to compare blocks. The sameBlock() method returns true if the dimensions match, and sameVolume() returns true if the volumes match. The main method creates Block objects and calls the methods to test equality. This demonstrates how objects can be passed to methods and their properties compared.
The document describes a Java program to calculate parcel shipping charges based on weight. It begins with an initial charge of Rs. 15 for the first 1KG. Any additional weight is charged Rs. 8 for every 500g or fraction thereof. The program takes a weight in KGs as input, calculates the remaining weight after deducting 1KG, determines the charge for full 500g increments and any fractional part, and outputs the total charge.
This document contains 9 Java programming assignments from a BCA semester course. Each assignment demonstrates a different Java concept such as typecasting, bitwise operators, string operations, inheritance, polymorphism, packages, interfaces, threads, and abstract classes. The assignments include code snippets to demonstrate the concepts and the expected output when the code is compiled and run.
Refer to my progress on this assignment belowIn this problem you w.pdfarishmarketing21
Refer to my progress on this assignment below
In this problem you will make it “more” object-oriented in the following ways:
-You will change its name to SortedList
-You will change the constructor that takes no arguments to be more traditional and initialize the
member fields to dummy values.
-You will add a constructor that takes in an initialized array and a size
-You will add an insert function that adds a value to the list and maintains its sorted-ness
-You will add a quicksort function check the below code.
-You will make updates as necessary to the main function so that it still runs and tests your code.
The code below seems to sort correctly but it skips over some items in the array and I am not
sure what is happening. Please help! Thanks!
import java.util.Scanner;
class SortedList
{
private static int array[];
private static int n;
public SortedList()
{
Scanner in = new Scanner(System.in);
System.out.println(\"Enter number of elements\");
n = in.nextInt();
array = new int[n];
if(n == 0) {
System.out.print(\"Since no arguments array set to: \");
} else {
System.out.print(\"Creating array size \" + n + \": \");
}
for(int i = 0; i < n; i++)
{
array[i] = 0;
}
//System.out.println(\"Enter \" + n + \" integers in ascending order\");
/*for (c = 0; c < n; c++)
array[c] = in.nextInt();*/
for(int i = 0; i < n; i++)
{
System.out.print(array[i] + \" \");
}
System.out.print(\"\ \");
}
public SortedList(int a[], int size)
{
array = a;
n = size;
}
public int binsearch(int search)
{
int first, last, middle;
first = 0;
last = n - 1;
middle = (first + last)/2;
while( first <= last )
{
if ( array[middle] < search )
first = middle + 1;
else if ( array[middle] == search )
{
//System.out.println(search + \" found at location \" + (middle + 1) + \".\");
return middle+1;//+1 for the non-CS people who don\'t start counting at zero.
}
else
last = middle - 1;
middle = (first + last)/2;
}
return -1;
//System.out.println(search + \" is not present in the list.\ \");
}
public static int partition(int input[], int p, int r)
{
int pivot = input[r];
while(p < r)
{
while(input[p] < pivot)
{
p++;
}
while(input[r] > pivot)
{
r--;
}
if(input[p] == input[r])
{
p++;
}
else if(p < r)
{
int tmp = input[p];
input[p] = input[r];
input[r] = tmp;
}
}
return r;
}
public static void quicksort(int input[], int p, int r)
{
if(p < r)
{
int j = partition(input, p, r);
quicksort(input, p, j-1);
quicksort(input, j+1, r);
}
}
public static void insert(int value, int cell)
{
array[cell] = value;
quicksort(array, 0, n-1);
}
public static void main(String args[])
{
int c;
Scanner in = new Scanner(System.in);
SortedList b = new SortedList();
System.out.println(\"Input numbers\");
for(int i = 0; i < n; i++)
{
c = in.nextInt();
in.nextLine();
insert(c, i);
}
in.close();
for(int j = 0; j < n; j++)
{
System.out.print(array[j] + \", \");
}
}
}
Solution
//the whole program that you wrote is correct except one line , when you call the quicksort
everytime you insert a //value dont pass n pass the i.
This document provides an overview of key concepts in Java and Python including:
- Programming paradigms like functional and object-oriented programming
- The compilation process in Java vs interpretation in Python
- Basic syntax for variables, data types, arithmetic and comparison operators, conditional statements, loops, classes and objects in both languages
- Examples of built-in functions for strings and numbers
- Concepts like aggregation, inheritance and polymorphism demonstrated through classes
Flutter vs. React Native: A Detailed Comparison for App Development in 2024dhavalvaghelanectarb
Choosing the right framework for your cross-platform mobile app can be a tough decision. Both Flutter and React Native offer compelling features and have earned their place in the development world. Here is a detailed comparison to help you weigh their strengths and weaknesses. Here are the pros and cons of developing mobile apps in React Native vs Flutter.
Streamlining End-to-End Testing Automation with Azure DevOps Build & Release Pipelines
Automating end-to-end (e2e) test for Android and iOS native apps, and web apps, within Azure build and release pipelines, poses several challenges. This session dives into the key challenges and the repeatable solutions implemented across multiple teams at a leading Indian telecom disruptor, renowned for its affordable 4G/5G services, digital platforms, and broadband connectivity.
Challenge #1. Ensuring Test Environment Consistency: Establishing a standardized test execution environment across hundreds of Azure DevOps agents is crucial for achieving dependable testing results. This uniformity must seamlessly span from Build pipelines to various stages of the Release pipeline.
Challenge #2. Coordinated Test Execution Across Environments: Executing distinct subsets of tests using the same automation framework across diverse environments, such as the build pipeline and specific stages of the Release Pipeline, demands flexible and cohesive approaches.
Challenge #3. Testing on Linux-based Azure DevOps Agents: Conducting tests, particularly for web and native apps, on Azure DevOps Linux agents lacking browser or device connectivity presents specific challenges in attaining thorough testing coverage.
This session delves into how these challenges were addressed through:
1. Automate the setup of essential dependencies to ensure a consistent testing environment.
2. Create standardized templates for executing API tests, API workflow tests, and end-to-end tests in the Build pipeline, streamlining the testing process.
3. Implement task groups in Release pipeline stages to facilitate the execution of tests, ensuring consistency and efficiency across deployment phases.
4. Deploy browsers within Docker containers for web application testing, enhancing portability and scalability of testing environments.
5. Leverage diverse device farms dedicated to Android, iOS, and browser testing to cover a wide range of platforms and devices.
6. Integrate AI technology, such as Applitools Visual AI and Ultrafast Grid, to automate test execution and validation, improving accuracy and efficiency.
7. Utilize AI/ML-powered central test automation reporting server through platforms like reportportal.io, providing consolidated and real-time insights into test performance and issues.
These solutions not only facilitate comprehensive testing across platforms but also promote the principles of shift-left testing, enabling early feedback, implementing quality gates, and ensuring repeatability. By adopting these techniques, teams can effectively automate and execute tests, accelerating software delivery while upholding high-quality standards across Android, iOS, and web applications.
What is Continuous Testing in DevOps - A Definitive Guide.pdfkalichargn70th171
Once an overlooked aspect, continuous testing has become indispensable for enterprises striving to accelerate application delivery and reduce business impacts. According to a Statista report, 31.3% of global enterprises have embraced continuous integration and deployment within their DevOps, signaling a pervasive trend toward hastening release cycles.
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...kalichargn70th171
Visual testing plays a vital role in ensuring that software products meet the aesthetic requirements specified by clients in functional and non-functional specifications. In today's highly competitive digital landscape, users expect a seamless and visually appealing online experience. Visual testing, also known as automated UI testing or visual regression testing, verifies the accuracy of the visual elements that users interact with.
In this infographic, we have explored cost-effective strategies for iOS app development, focusing on building high-quality apps within a budget. Key points covered include prioritizing essential features, leveraging existing tools and libraries, adopting cross-platform development approaches, optimizing for a Minimum Viable Product (MVP), and integrating with cloud services and third-party APIs. By implementing these strategies, businesses and developers can create functional and engaging iOS apps while minimizing development costs and time-to-market.
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...Luigi Fugaro
Vector databases are transforming how we handle data, allowing us to search through text, images, and audio by converting them into vectors. Today, we'll dive into the basics of this exciting technology and discuss its potential to revolutionize our next-generation AI applications. We'll examine typical uses for these databases and the essential tools
developers need. Plus, we'll zoom in on the advanced capabilities of vector search and semantic caching in Java, showcasing these through a live demo with Redis libraries. Get ready to see how these powerful tools can change the game!
Secure-by-Design Using Hardware and Software Protection for FDA ComplianceICS
This webinar explores the “secure-by-design” approach to medical device software development. During this important session, we will outline which security measures should be considered for compliance, identify technical solutions available on various hardware platforms, summarize hardware protection methods you should consider when building in security and review security software such as Trusted Execution Environments for secure storage of keys and data, and Intrusion Detection Protection Systems to monitor for threats.
Transforming Product Development using OnePlan To Boost Efficiency and Innova...OnePlan Solutions
Ready to overcome challenges and drive innovation in your organization? Join us in our upcoming webinar where we discuss how to combat resource limitations, scope creep, and the difficulties of aligning your projects with strategic goals. Discover how OnePlan can revolutionize your product development processes, helping your team to innovate faster, manage resources more effectively, and deliver exceptional results.
Building API data products on top of your real-time data infrastructureconfluent
This talk and live demonstration will examine how Confluent and Gravitee.io integrate to unlock value from streaming data through API products.
You will learn how data owners and API providers can document, secure data products on top of Confluent brokers, including schema validation, topic routing and message filtering.
You will also see how data and API consumers can discover and subscribe to products in a developer portal, as well as how they can integrate with Confluent topics through protocols like REST, Websockets, Server-sent Events and Webhooks.
Whether you want to monetize your real-time data, enable new integrations with partners, or provide self-service access to topics through various protocols, this webinar is for you!
Enhanced Screen Flows UI/UX using SLDS with Tom KittPeter Caitens
Join us for an engaging session led by Flow Champion, Tom Kitt. This session will dive into a technique of enhancing the user interfaces and user experiences within Screen Flows using the Salesforce Lightning Design System (SLDS). This technique uses Native functionality, with No Apex Code, No Custom Components and No Managed Packages required.
Consistent toolbox talks are critical for maintaining workplace safety, as they provide regular opportunities to address specific hazards and reinforce safe practices.
These brief, focused sessions ensure that safety is a continual conversation rather than a one-time event, which helps keep safety protocols fresh in employees' minds. Studies have shown that shorter, more frequent training sessions are more effective for retention and behavior change compared to longer, infrequent sessions.
Engaging workers regularly, toolbox talks promote a culture of safety, empower employees to voice concerns, and ultimately reduce the likelihood of accidents and injuries on site.
The traditional method of conducting safety talks with paper documents and lengthy meetings is not only time-consuming but also less effective. Manual tracking of attendance and compliance is prone to errors and inconsistencies, leading to gaps in safety communication and potential non-compliance with OSHA regulations. Switching to a digital solution like Safelyio offers significant advantages.
Safelyio automates the delivery and documentation of safety talks, ensuring consistency and accessibility. The microlearning approach breaks down complex safety protocols into manageable, bite-sized pieces, making it easier for employees to absorb and retain information.
This method minimizes disruptions to work schedules, eliminates the hassle of paperwork, and ensures that all safety communications are tracked and recorded accurately. Ultimately, using a digital platform like Safelyio enhances engagement, compliance, and overall safety performance on site. https://safelyio.com/
The Rising Future of CPaaS in the Middle East 2024Yara Milbes
Explore "The Rising Future of CPaaS in the Middle East in 2024" with this comprehensive PPT presentation. Discover how Communication Platforms as a Service (CPaaS) is transforming communication across various sectors in the Middle East.
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...The Third Creative Media
"Navigating Invideo: A Comprehensive Guide" is an essential resource for anyone looking to master Invideo, an AI-powered video creation tool. This guide provides step-by-step instructions, helpful tips, and comparisons with other AI video creators. Whether you're a beginner or an experienced video editor, you'll find valuable insights to enhance your video projects and bring your creative ideas to life.
2. Syntax Of Classes
♦♦ Simple class ♦♦
<class- keyword> <class- name>
{
<method- access specifier> <type- return/non_return> <method- name>()
{ operations }
}
♦♦ static top most class ♦♦
<static- keyword><class- keyword> <class- name>
{
<method- access specifier> <type- return/non_return> <method- name>()
{ operations }
}
♦♦ main class ♦♦
<class- keyword> <class- name>
{
public static void main (String [ ]s )
{
System.out.println(“Welcome In BHABHA GROUP OF INSTITUTION”) ;
}
}
3. ♦♦1 program to add two number ♦♦
class sum
{
public static void main(String[]s)
{
int a,b,c;
a=Integer.parseInt(s[0]);
b=Integer.parseInt(s[1]);
c=a+b;
System.out.println("sum = "+c);
} }
♦♦2 program to multiply two number ♦♦
class multi
{
public static void main(String[]s)
{
int a,b,c;
a=Integer.parseInt(s[0]);
b=Integer.parseInt(s[1]);
c=a*b;
System.out.print("sum = "+c);
}
}
4. ♦♦3 program to print factorial of any number ♦♦
class factorial
{
public static void main(String[]s)
{
int a,f=1;
a=Integer.parseInt(s[0]);
for(int i=a;i>=1;i--)
{ f=f*i; }
System.out.println("Factorial of n = "+f);
} }
♦♦4 program to find number is palindrom or not♦♦
class palindrom
{
public static void main(String[]s)
{
int a,b,c=0,d;
a=Integer.parseInt(s[0]);
d=a;
do
{ b=a%10;
c=c*10+b;
a=a/10; }
while(a>0);
if(d==c)
System.out.println("number is palindrom "+d);
else System.out.println("number is not palindrom "+d); } }
5. ♦♦5 program to find out no.is Armstrong or not ♦♦
class armstrong
{
public static void main(String[]s)
{
int a,b,c=0,d;
a=Integer.parseInt(s[0]);
{
d=a;
do
{ b=a%10;
c=c+b*b*b;
a=a/10; }
while(a>0);
if(d==c)
System.out.println("number is armstrong "+d);
else System.out.println("number is not armstrong "+d); } } }
♦♦6 program to find out even & odd number ♦♦
class number
{
public static void main(String[]s)
{
int a,b;
a=Integer.parseInt(s[0]);
b=Integer.parseInt(s[1]);
for(int i=a;i<=b;i++)
{ if(i%2==0)
System.out.println("Number is even = "+i);
6. else System.out.println("Number is odd = "+i); } } }
♦♦7 program to print the table from “x” to “y”♦♦
class table
{
public static void main(String []s)
{
int a,b;
a=Integer.parseInt(s[0]);
b=Integer.parseInt(s[1]);
if(a<=b)
{
for(int i=a;i<=b;i++)
{
for(int j=1;j<=10;j++)
{
System.out.print(j*i+" ");
}
System.out.println(" ");
}}
else
{
for(int i=b;i<=a;i++)
{
for(int j=1;j<=10;j++)
{
System.out.print(j*i+" ");
}
System.out.println(" ");
}
}
}
}
7. ♦♦ 8 program to print no. in various format ♦♦
class print
{
public static void main(String[]s)
{
int a,b;
a=Integer.parseInt(s[0]);
b=Integer.parseInt(s[1]);
for(int i=a;i<=b;i++)
{
for(int j=a;j<=i;j++)
{
System.out.print(" "+j);
}
System.out.println(" ");
} System.out.println(" ");
for(int i=b;i>=a;i--)
{
for(int j=a;j<=i;j++)
{
System.out.print(" "+j);
}
System.out.println(" ");
}
System.out.println(" ");
for(int i=b;i>=a;i--)
{
for(int j=b;j>=i;j--)
{
System.out.print(" "+j);
9. ♦♦ 9 program Of Overriding ♦♦
class x
{
public void test(int a,int b )
{
int c= a + b ;
System.out.println("from class x sum ="+c);
}
}
class y extends x
{
public void test(int a,int b )
10. {
int c= a * b ;
System.out.println("from class y multiplication ="+c);
}
}
class overriding
{
public static void main(String [ ]s)
{
int a,b;
a=Integer.parseInt(s[0]);
b=Integer.parseInt(s[1]);
y obj=new y( );
obj.test(a,b);
}
}
♦♦ 10 program Of Overloading ♦♦
class x
{
public void test(int a, int b )
{
int c = a * b ;
System.out.println("multiplication of number = "+c);
} }
class y
{
public void test(int a, int b, int d )
11. {
int c= a + b + d ;
System.out.println("sum of given number = "+c);
} }
class overloading
{
public static void main (String [ ] s)
{
int a=Integer.parseInt(s[0]);
int b=Integer.parseInt(s[1]);
int d=Integer.parseInt(s[2]);
x obj = new x( );
obj.test(a ,b );
y obj1 = new y( );
obj1.test(a ,b ,d );
} }
♦♦11 Communication of class by creating object♦♦
class A
{
public void show( )
{
System.out.println("welcome from A");
}
}
class B
{
public void show1( )
12. {
A obj=new A( );
obj.show( );
}
}
class C
{
public static void main (String [ ] s)
{
B obj=new B( );
obj.show1( );
}
}
♦♦ 12 Communication of class by inheritance ♦♦
class A
{
public void show( )
{
System.out.println("welcome from A");
} }
class B extends A
{
public void show1( )
{
System.out.println("welcome from B");
} }
13. class D
{
public static void main (String [ ] s)
{
B obj = new B( );
obj.show( );
} }
♦ 13 Area of circle & rectangle using object ♦
class circle
{
public void area_c(int r )
{
int ar;
ar=r*r*22/7;
System.out.println("Area of circle= "+ar);
}
}
class rect
{
14. public void area_rec(int le, int br )
{
int ar;
ar=le*br;
System.out.println("Area of rectangle= "+ar);
}
}
class area
{
public static void main (String [ ] s)
{
int r=Integer.parseInt(s[0]);
int le=Integer.parseInt(s[1]);
int br=Integer.parseInt(s[2]);
circle obj=new circle( );
obj.area_c(r );
rect obj1=new rect( );
obj1.area_rec(le, br );
}
}
♦♦14 use of abstract class ♦♦
abstract class test
{
abstract public void show( );
{ }
}
class help extends test
{
public void show( )
{
System.out.println(" from class help ");
} }
15. class take extends test
{
public void show( )
{
System.out.println(" from class take ");
} }
class give extends test
{
public void show( )
{
System.out.println(" from class give ");
} }
class abstractdemo
{
public static void main (String [ ] s)
{
help obj=new help( );
obj.show( );
take obj1=new take( );
obj1.show( );
give obj2=new give( );
obj2.show( ); } }
16. ♦♦ 15 use of package ♦♦
packagea;
public class a1
{ public void sum(inta, int b)
{ int c= a + b;
System.out.println("sum="+c); } }
packagea;
public class a5
{ public void fact(int a, int b)
{for(inti=a;i<=b;i++)
{ int f=1;
for(intj=i;j>=1;j--)
{ f=f*j; }
System.out.print("Factof "+i);
System.out.println("="+f); } } }
packagea;
public class a4
{ public void table(int a,int b)
{ for(int i=a;i<=b;i++)
{ System.out.print("tableof "+i);
System.out.print("=");
for(intj=1;j<=10;j++)
{ System.out.print(" "+j*i); }
System.out.println(" "); } } }
packagea;
public class a3
{ public void mul(int a, int b)
{ int c= a * b;
System.out.println("mul="+c); } }
packagea;
public class a2
{ public void sub(inta, int b)
{ if(a>b)
{ int c= a - b;
System.out.println("sub ="+c); }
else
{ int c= b - a;
System.out.println("sub ="+c); } } }
17. import a.*;
class cal
{ public static void main(String []s)
{ int a=Integer.parseInt(s[0]);
int b=Integer.parseInt(s[1]);
a1 obj=new a1();
obj.sum(a,b);
a2 obj1=new a2();
obj1.sub(a,b);
a3 obj3=new a3();
obj3.mul(a,b);
a4 obj4=new a4();
obj4.table(a,b);
a5 obj5=new a5();
obj5.fact(a,b); } }
18. ♦♦ 16 “try” and “catch” block ♦♦
class ab
{
public static void main(String [ ]s)
{
try
{
int i=Integer.parseInt(s[0]);
int j=Integer.parseInt(s[1]);
int k=i/j;
System.out.print("result="+k);
}
catch(Exception e)
{System.out.print(e);}
}
}
19. ♦♦17 Userthread by extending Thread class ♦♦
class abc extends Thread
{
public abc()
{
start();
}
public void run()
{
try
{
for(int i=5;i<=9;i++)
{ System.out.print("table of "+i);
System.out.print("=");
for(int j=1;j<=10;j++)
{ System.out.print(" "+j*i); }
System.out.println(" ");
sleep(500);
}
}
catch(Exception e)
{System.out.print(e);}
}
}
class test
{
public static void main (String []s)
{
try
{
abc obj=new abc();
}
catch(Exception e)
{System.out.print(e);}
} }
20. ♦♦18 multiplethread with join(); ♦♦
class sud extends Thread
{
String name;
public sud(String name)
{
this.name=name;
start();
}
public void run()
{
try
{
for(int i=0;i<5;i++)
{
System.out.println("name =" +" " +name +"=" +i);
sleep(500);
}
}
catch(Exception e)
{System.out.print(e);}
}
}
class main
{
public static void main(String []s)
{
try
{
sud one=new sud("first ");
sud sec=new sud("second");
sud third=new sud("third ");
sec.join();
one.join();
third.join();
for(int i=0;i<5;i++)
{
System.out.println("main = " +i);
}
}
catch(Exception e)
{System.out.print(e);}
}
}
21.
22. ♦♦19 Take input until char= ’z’ in io-package ♦♦
import java.io.*;
classabc
{
public static void main(String []s)
{
char c;
try
{
BufferedReader B=new BufferedReader(new
InputStreamReader(System.in));
do
{
System.out.print("enter until z =");
c=(char)B.read();
}
while(c!= 'z');
}
catch(Exception e)
{System.out.print(e);}
}
}
23. ♦♦20 Take input until string=’off’ in io package
import java.io.*;
classabc
{
public static void main(String []s)
{
String l;
try
{
BufferedReader B=new BufferedReader(new
InputStreamReader(System.in));
do
{
l=B.readLine();
System.out.print("enter until off =");
if(l.equals ("off"))
{break;}
}
while(true);
}
catch(Exception e)
{System.out.print(e);}
}
}
24. ♦♦21 Open a file in read mode in io-package ♦♦
import java.io.*;
class file
{
public static void main(String []s)
{
try
{
FileInputStream B=new FileInputStream("sud.txt");
while (B.read()!=-1)
{
char c=(char)B.read();
System.out.print(c);
}
}
catch(Exception e)
{System.out.print(e);}
}
}
25. ♦♦22insert value in database ♦♦
importjava.sql.*;
class insert
{
public static void main(String []s)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection
con=DriverManager.getConnection("Jdbc:Odbc:Contact_detail");
PreparedStatementpst=con.prepareStatement("insert into
values('abc' ,+918009000260,'abc@gmail.com')");
pst.close();
con.close();
}
catch(Exception e)
{System.out.print(e);}
}
}
♦♦23featch value from database ♦♦
importjava.sql.*;
classfeatch
{
public static void main(String []s1)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection
con=DriverManager.getConnection("Jdbc:Odbc:Contact_detail");
Statement smt=con.createStatement();
ResultSetrs=smt.executeQuery("select * from emp");
while(rs.next())
{
int a=rs.getInt(1);
String s=rs.getString(2);
System.out.print(a +" " +s);
} }
catch(Exception e)
{System.out.print(e);}
}}
26. <HTML>
<from method=”get” action=”demo”>Enter the number : -
<input type="text" name="number"/><br>
<input type="submit" name="submit"/><br>
</form></html>
♦♦24Display Welcome with user Servlat♦♦
import java.io.*;
importjavax.servlet.*;
public class demo extends GenericServlet
{
publi void service(ServletRequestreq,ServletResponse res)
throws ServletException, IOexception
{
res.setContent Type("text/HTML");
PrintWriter out=res.getWriter();
for(inti=0;i<10;i++)
{
out.print("Welcome");
} } }
♦25receive data from HTML and cheak even/odd ♦
import java.io.*;
importjavax.servlet.*;
public class demo extends GenericServlet
{
publi void service(ServletRequestreq,ServletResponse res)
throws ServletException, IOexception
{
res.setContent Type("text/HTML");
PrintWriter out=res.getWriter();
int a=Interger.ParseInt(req.getParameter("number"));
if(a%2==0)
27. <html><form method="get" action="first">
Enter Name:-<input type="text" name="name"/><br><br>
Enter Password :- <input type="password" name="password"/><br><br>
<input type="submit" name="submit"/><br>
</form></html>
import java.io.*;
importjavax.servlet.*;
importjavax.servlet.http.*;
public class firstextends GenericServlet
{
public void service(ServletRequestreq,ServletResponseres) throws
ServletException, IoException
{
RequestDispatcherrd=req.getRequestDispatcher("home")
res.setContentType("text/HTML");
PrintWriter out=res.getWriter();
String name=(String)req.getParameter("name");
String password=(String)req.getParameter("password");
if (name.equals("sudeep") &&password.equals("abc123"))
rd.forword(req, res)
out.print("Number is even = "+a);
else
out.print("Number is odd = "+a);
}}
♦♦ 26passing values between servlet ♦♦
“login.html”
“first.java”