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.
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.
Running head: Java Assignment Codes1 Java Assignment Codes Student Name Institution Location of Institution Professor’s Name Date
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
Java Assignment Codes2 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 Codes3 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 Codes4 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("CounterSum 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); }
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Java Assignment Codes6 ) { for (String comb : combs) { System.out.println(comb); } } } public static void main(String[] args) { // TODO code application logic here new Counter(); } }
Java Assignment Codes7 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;
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
Java Assignment Codes8 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 Codes9 for (c = b + 1; b <= n; b++) { for (d = c + 1; b <= n; b++) { for (e = d + 1; b <= n; b++) { for (f = e + 1; b <= n; b++) { counter++; if ((a + b + c + d + e + f) == n) { combs.add(a + " +" + b + " +" + c + " +" + d + " +" + e + " +" + f + "= " + n); } if ((a + b + c + d + e + f) == n) { sum_counter++; System.out.println(counter +""+sum_counter+""+a+""+b+" "+c+""+d+""+e+""+f ); } else { System.out.println(counter +""+a+""+b+""+c+""+d+" "+e+""+f ); } } }
Java Assignment Codes19 1.4 Question Three 1.4.1 Main Class /* * 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 hilbert.curve; import java.awt.BorderLayout; import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JApplet; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.SwingConstants;
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
Java Assignment Codes26 public static void main(String[] args) { // TODO code application logic here JApplet applet = new HilbertCurves(); applet.init(); applet.start(); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setTitle("Hilbert Curves"); frame.getContentPane().add(applet, BorderLayout.CENTER); frame.setSize(512, 512); frame.setVisible(true); } }
Java Assignment Codes27 1.4.2 Applet <!DOCTYPE html> <!-- 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. --> <html> <head> </head> <body> <applet code="HilbertCurves.class" width="250" height="50"></applet> </body> </html>