Question
okay so i have a student project and its three differnt projects a, b and c and they all need to be in seperate files
okay so i have a student project and its three differnt projects a, b and c and they all need to be in seperate files to be turned in I have a code with no errors for a and b but im confused on what to do with c
This is Part A insruction:
Part A Desktop Loop Comparison Console Application Which Loop structure is the fastest?
1. Learn some of the similarities and differences between the C# and Java programming languages.
2. Use imported java.util Calendar and Date classes to compute elapsed time for loop processing.
3. Use static class variables, local variables, and static methods in an application.
4. Develop a console application that will compute the average processing speed for each of the three Java loop structures in order to determine the fastest loop processing structure
5. Use two Math class methods for math calculations.
6. Use nested If statements to determine fastest processing time.
7. Use imported java.text DecimalFormat and NumberFormat classes to display times with four decimal places.
8. Create and call methods (modular blocks of code) for each type of loop structure. Use the Main method to call other methods.
9. Create a .jar file to make a distributable Java console application.
10. Use a onedimensional array to store the loop processing times for the ten loop iterations. (You will run each loop structure ten times in order to compute an average time.)
11. Compute an average processing time from the processing times stored in the array.
12. Learn to use the textbook and Internet as a reference sources for Java problems/topics.
13. Learn that there is a processing speed difference in the three loop structures.
14. Learn to create a Java application with limited instructions.
This is my code so far for A
import java.util.*; import java.text.SimpleDateFormat; /** * * @author coleen */
import java.util.*; import java.text.SimpleDateFormat; public class StudentProject { static double forLoopElapsedTime = 0; static double whileLoopElapsedTime = 0; static double doWhileLoopElapsedTime = 0;
public static void calculateForLoopExecTime() { System.out.println(" ==== For Loop Execution Time ======"); System.out.println("Start Time = " + new SimpleDateFormat("hh:mm:ss a").format(new Date())); double startTime = System.currentTimeMillis(); long total = 0; for (int i = 0; i < 10000000; i++) { total += i; } System.out.println("End Time = " + new SimpleDateFormat("hh:mm:ss a").format(new Date())); double stopTime = System.currentTimeMillis(); forLoopElapsedTime = (stopTime - startTime)/1000; System.out.println("Elapsed Time = " + forLoopElapsedTime + " seconds"); System.out.println("Completed Loops = " + total); }
public static void calculateWhileLoopExecTime(){ System.out.println(" ==== While Loop Execution Time ======"); System.out.println("Start Time = " + new SimpleDateFormat("hh:mm:ss a").format(new Date())); double startTime = System.currentTimeMillis(); long total = 0; long i = 0; while(i < 10000000){ total += i; i++; } System.out.println("End Time = " + new SimpleDateFormat("hh:mm:ss a").format(new Date())); double stopTime = System.currentTimeMillis(); whileLoopElapsedTime = (stopTime - startTime)/1000; System.out.println("Elapsed Time = " + whileLoopElapsedTime + " seconds"); System.out.println("Completed Loops = " + total); }
public static void calculateDoWhileLoopExecTime(){ System.out.println(" ==== Do While Loop Execution Time ======"); System.out.println("Start Time = " + new SimpleDateFormat("hh:mm:ss a").format(new Date())); double startTime = System.currentTimeMillis(); long total = 0; long i = 0; do { total += i; i++; } while(i < 10000000); System.out.println("End Time = " + new SimpleDateFormat("hh:mm:ss a").format(new Date())); double stopTime = System.currentTimeMillis(); doWhileLoopElapsedTime = (stopTime - startTime)/1000; System.out.println("Elapsed Time = " + doWhileLoopElapsedTime + " seconds"); System.out.println("Completed Loops = " + total); }
}
This is B instructions:
Part B GUI Loop Comparison Application Which Loop structure is the fastest?
1. Learn to convert a Java console application to a GUI application.
2. Use imported Swing class to create Java GUI form.
3. Learn to add controls to a Java GUI form.
4. Learn to modify form control properties with Java code
. 5. Learn to attach Java code to form controls so application is user eventdriven.
6. Learn to create a .jar file to distribute a Java GUI application.
and this is my code:
package studentproject;
import static studentproject.StudentProject.calculateDoWhileLoopExecTime; import static studentproject.StudentProject.calculateForLoopExecTime; import static studentproject.StudentProject.calculateWhileLoopExecTime; import static studentproject.StudentProject.doWhileLoopElapsedTime; import static studentproject.StudentProject.forLoopElapsedTime; import static studentproject.StudentProject.whileLoopElapsedTime;
/** * * @author coleen */ public class assignmentB { public static void compareElaspedTime() { System.out.print(" ");
if(forLoopElapsedTime< whileLoopElapsedTime) { if(forLoopElapsedTime < doWhileLoopElapsedTime) { System.out.println("Fastest execution time : For Loop " +forLoopElapsedTime+ " seconds"); } else { System.out.println("Fastest execution time : Do While Loop " +doWhileLoopElapsedTime+ " seconds"); } } else { if(whileLoopElapsedTime< doWhileLoopElapsedTime) { System.out.println("Fastest execution time : While Loop " +whileLoopElapsedTime+ " seconds"); } else { System.out.println("Fastest execution time : Do While Loop " +doWhileLoopElapsedTime+ " seconds"); } } }
public static void main(String[] args) { System.out.println("Average Elapsed Time for 10,000,000 loops in seconds"); /*calculateForLoopExecTime(); */ calculateWhileLoopExecTime(); calculateDoWhileLoopExecTime(); compareElaspedTime(); } }
and this is instructions for C:
Part C Loop Comparison Applet Which Loop structure is the fastest?
1. Learn to convert a Java Desktop/GUI application into an Applet.
2. Learn to integrate HTML with a Java Applet.
3. Learn to use a browser to view the output from a Java Applet.
Sorry this is so long!! But my question after all this is,
do my codes look right? and what the heck do i do with C?
Please and thank you!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started