logo

Java Assignment Codes

Solve programming assignments using Java and produce a word-processed report following the suggested format.

52 Pages5341 Words240 Views
   

Added on  2023-05-30

About This Document

Get Java assignment codes for Counter, Traffic Lights and Hilbert Curves. Learn Java programming with Desklib's online library for study material with solved assignments, essays, dissertation etc.

Java Assignment Codes

Solve programming assignments using Java and produce a word-processed report following the suggested format.

   Added on 2023-05-30

ShareRelated Documents
Running head: Java Assignment Codes 1
Java Assignment Codes
Student Name
Institution
Location of Institution
Professor’s Name
Date
Java Assignment Codes_1
Java Assignment Codes 2
Table of Contents
1.1 Question One Part One..............................................................................................................3
1.2 Question One Part Two.............................................................................................................7
1.3 Question Two...........................................................................................................................11
1.4 Question Three.........................................................................................................................19
1.4.1 Main Class........................................................................................................................19
1.4.2 Applet...............................................................................................................................27
1.5 Question Four..........................................................................................................................28
1.5.1 Morse Code Client............................................................................................................28
1.5.2 Morse Code Server...........................................................................................................44
Java Assignment Codes_2
Java Assignment Codes 3
1.1 Question One Part One
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package counter;
import java.util.ArrayList;
import java.util.Scanner;
/**
*
* @author Keeprawteach
*/
public class Counter {
/**
* @param args the command line arguments
*/
int k, m, counter, sum_counter;
Java Assignment Codes_3
Java Assignment Codes 4
public Counter() {
Scanner in = new Scanner(System.in);
System.out.println("Enter number: ");
int x = in.nextInt();
DoCalculations(x);
}
void DoCalculations(int n) {
System.out.println("Counter Sum Counter| n | m");
ArrayList<String> combs = new ArrayList<>();
counter = 0;
sum_counter = 0;
for (k = 1; k < n; k++) {
for (m = k + 1; m <= n; m++) {
counter++;
if ((k + m) == n) {
combs.add(k + " + " + m + " = " + n);
}
Java Assignment Codes_4
Java Assignment Codes 5
if ((k + m) == n) {
sum_counter++;
System.out.println(" " + counter + " " + sum_counter + " " + k + "
" + m);
}else{
System.out.println(" " + counter + " " + k + " " + m);
}
}
}
System.out.println (
"\n\n");
System.out.println (
"Total Combinations: " + String.valueOf(combs.size()));
System.out.println (
"\n\nCombinations:\n");
if (!combs.isEmpty ()
Java Assignment Codes_5
Java Assignment Codes 6
) {
for (String comb : combs) {
System.out.println(comb);
}
}
}
public static void main(String[] args) {
// TODO code application logic here
new Counter();
}
}
Java Assignment Codes_6
Java Assignment Codes 7
1.2 Question One Part Two
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package counter.part.two;
import java.util.ArrayList;
import java.util.Scanner;
/**
*
* @author Keeprawteach
*/
public class CounterPartTwo {
/**
* @param args the command line arguments
*/
int a, b, c, d, e, f, counter, sum_counter;
Java Assignment Codes_7
Java Assignment Codes 8
public CounterPartTwo() {
Scanner in = new Scanner(System.in);
System.out.println("Enter number: ");
int x = in.nextInt();
DoCalculations(x);
}
public static void main(String[] args) {
// TODO code application logic here
new CounterPartTwo();
}
private void DoCalculations(int n) {
System.out.println("Counter | Sum Counter | a | b | c | d | e | f ");
ArrayList<String> combs = new ArrayList<>();
counter = 0;
sum_counter = 0;
for (a = 1; a < n; a++) {
for (b = a + 1; b <= n; b++) {
Java Assignment Codes_8

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Java Programming | Assignment
|9
|834
|20

Object Oriented Programming with Java
|9
|1142
|153

Average Numbers Importance of Five Numbers
|15
|4930
|206

Online Sales and Inventory Management System (SIMS)
|18
|4838
|56

Programming Assignment: Java Programming
|12
|2732
|107

Java Programming Assignment: Comma-Separated Integer Inputs and Exception Handling
|8
|937
|481