JDK 13 with JavaFX 11 USB Portable Environment

  • Download this 473MB zip file
  • Unzip the contents onto a freshly formatted USB drive.
  • Make sure the root of the USB has these 3 directories: eclipse, Java, workspace, and 1 file called js.cmd.
  • When you want to start coding in this environment, click the js.cmd file. It will launch eclipse.
  • Projects get stored in the workspace directory.
  • Be sure to exit eclipse and wait for the shell window to close. Then eject the USB drive, or you will lose your work!

JavaFX11 is installed on this image. It’s use in a project will be discussed in the CSC-112 Intermediate Java course.

JDK 10 USB Portable Environment

  • Download this 612MB zip file
  • Unzip the contents onto a freshly formatted USB drive.
  • Make sure the root of the USB has these 3 directories: eclipse, Java, workspace, and 1 file called js.cmd.
  • When you want to start coding in this environment, click the js.cmd file. It will launch eclipse.
  • Projects get stored in the workspace directory.
  • Be sure to exit eclipse and wait for the shell window to close. Then eject the USB drive, or you will lose your work!

Why JDK 10? It’s the last version of the JDK that has JavaFX built in. JavaFX is a technology that allows building GUI code. We will use that technology in the CSC-112 Intermediate Java course.

That’s not to say the newer JDKs can’t compile JavaFX. It’s that JavaFX is a separate download and is a chore to incorporate in the JDK.

Sign up for a GitHub Account

If you going to be a programmer, then github is a site you’ll need to use.

Go here: https://github.com/ and create an account for yourself.  We will be using github for homework submissions.

In particular the part of github we’ll  be using is the gist function located here:

https://gist.github.com/

You can submit multi-file projects under just one URL! You also have a record of all your work in one convenient location.

Use the TEMPLATE!!!

A few things apparently need to be explicitly stated as far as homework is concerned.

In case things are not mentioned in the homework, the following criteria ALWAYS apply:

  • Code must use the template.
  • Code needs to be written using the JDK 8 or better.
  • Code needs to contain the global header information mentioned in the syllabus.  All source code files must have the global header.
  • Code must be formatted properly using Eclipse’s formatting capabilities.
  • Code must use methods and classes to separate the logic.
  • Always email me gists of your source code.

Links and Resources for Java Courses

Liang 11th Edition Resources

Common Resources

HW10 Quadratic Equations with Solution

Solution

Due Friday, December 13, 11: 59pm

Design a class named Quadratic for a quadratic equation ax2 + bx + c = 0.

The solution to the quadratic equation is given by this formula:

The class contains:

  • Private data fields a, b, and c that represent three coefficients.
  • A constructor with arguments for a, b, and c.
  • A method named noOfRoots() that returns the number of real roots for the quadratic, either 0, 1, or 2
  • Methods getRoot1() and getRoot2() that returns the roots. These methods are useful only if the noOfRoots is nonnegative.

Download this driver class to test your implementation: QuadraticDriver.java (Do Not Change the Driver at all.)

Lucky for Life Lottery Number Generator

Solution

Write an application to help choose the Lucky for Life lottery numbers.

The Lucky for Life Numbers follow these rules:

  • Pick a group of 5 numbers from the numbers 1 to 43, inclusive (NO DUPLICATES!)
  • Pick 1 number (the LUCKY BALL number) out of the numbers 1 to 43.  This one number can duplicate one of the 5 already picked above.  This Lucky Ball number is totally independent of the group of 5 picked above.

Your application should prompt for the number of quick picks desired.  It will then generate and output that many Lucky of Life numbers.

The group of 5 numbers in each quick pick must be sorted.  The lucky ball is printed after the group of 5.; it is not involved in the sort.

Make sure your generator program keeps generating these numbers by asking the user if they would like to run the generator again.  Use the Project Template.  In fact, use this template for all future assignments as well.

Happy Computing!

HW8 Computing Standard Deviation with Solution

Solution

Due: Friday, November 15 11:59pm

Problem 7.11 (Computing Deviation) page 278.  Write your program to read a data file. You’ll prompt for a filename and use that name to open and read a data file.  You may either read the data off your machine’s hard drive as a file, or read it from a website.  Assume the data file has an integer as its first number that indicates the number of data points that follow in the file.  Here is some sample code to read the data: Sample Data File Reading Code

Make sure you use the Application Template so you can process multiple data files.  Code as many methods as you can that make sense to create this application.

Here are 3 different data files.  Download and copy them into your project folder.   They are also located on my website:  https://cs.stcc.edu/~silvestri/csc111/

These data files were generated from a website: https://random.org/

problem7-11

 

HW7 Calculate sin(x) or cos(x) using loops and methods with Solution

Retake Due: Wednesday, Nov. 6 10:00am

Do the cosine series as opposed to the sine. Same requirements as the original sine assignment.

Due: Friday, Nov. 1, 2019 11:59pm

Solution

Write an application that uses the template that calculates the sin(x).  The sin(x) can be calculated using the following series:

A program consisting of only a main method will not get you a passing grade.  You must break up your logic into as many methods as necessary to solve this problem.  The more methods, the better the grade.

At the very minimum, for each run of the logic, you will prompt the user for x (in degrees).  Remember, the series requires x to be in radians.  (Use Math.PI / 180 as your conversion factor.)  You will also prompt the user for the number of terms to calculate in the series.  You’ll output your series calculation, as well as Math.sin(x), and the difference between the two values to see how close your calculation is.

At the end of your logic, you’ll ask the user if they want to repeat the calculations.

Your grade will be based on the following criteria:

  • how much of the application is finished
  • whether it works
  • if you coded methods
  • the number of methods
  • if you formatted the output values using the printf method (assume just 6 decimal places for the output display)

CSC-111 In Class Looping Exercise

Due: 12:00pm today

Write code that keeps prompting for a positive number. When it gets that positive number, it keeps track of the largest positive number it finds.

If a negative number is entered, quit the process and print out the largest positive number.

Copy and Paste this code to get you started:

// Put your name here

import java.util.Scanner;

public class FindMaximumValue {

 public static void main(String[] args) {
     Scanner input = new Scanner(System.in); 
     System.out.print("Enter a positive number: ");
     int max = input.nextInt();     
     if (max < 0) {
        System.out.println("Can't Do this problem.");
        System.out.println("You can't follow directions.");
     }
     else {
         // Now write code that keeps prompting
         // for a positive number and keeps track
         // of the largest positive number it finds.


         // ...


     }
     input.close(); 
  }

}

HW5 Check SSN Problem with Solutions

Solutions: https://gist.github.com/bytecodeman/fe5ff16136c317e13120a1c91618a7dc

Due: Tuesday, Oct 15 11:59pm

checkssnSome additional requirements:

  • Enter the SSN as a String.
  • An SSN can have OPTIONAL HYPHENS!  But if they are there, they both need to be in their proper spots. So 123456789 and 123-45-6789 are both valid SSNs.
  • DO NOT USE LOOPS.  We haven’t studied them yet.  If you know loops, this problem will give you an appreciation for them.
  • Use the methods discussed in Chapter 4 as much as possible!
  • To avoid deep nesting of if statements, use a boolean variable and  expressions that look like:
boolean isValid = true;
isValid = isValid && character1 is a digit;
isValid = isValid && character2 is a digit;
. . .
  • Just to give yourself confidence in the expressions involving isValid, write the program assuming an SSN only has 2 digits.  Extending to 9 digits would be trivial.  Adding optional hypen logic would then be marginally harder.

Happy Coding!

CSC-111 In-class Exercise FizzBuzz with Solution

Alex Hartley’s Solution

Due in class only!!!

A classic interview question used by companies to see if a potential employee can really program is the FizzBuzz problem.

Enter a number. If the number is divisible by 3, output “Fizz”. If it is divisible by 5, output “Buzz”. If it is divisible by 3 and 5, output “FizzBuzz”. If the number doesn’t meet any of the divisibility rules, simply output the number.

Authenticate a User Code

Prompt for a Username and Password.

The credentials to check for proper access is:

Username: CSC-111
Password: JavaIsGood

Typically a username is checked with case insensitivity. Capital-A and lowercase-a are the same.  Passwords are always case sensitive.

If the user enters the proper info, they are allowed access to the system and you will print out: “Access Allowed”.

If not, print: “Credentials Not Correct.  Access Denied!!!”

https://pastebin.com/bKva1Jut

In class Chapter 3 Challenge

(Game: pick a card) Write a program that simulates picking a card from a deck of 52 cards. Your program should display the rank (Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King) and suit (Clubs, Diamonds, Hearts, Spades) of the card.

Here is a sample run of the program:

The card you picked is Jack of Hearts

Rules for Homework!!!

A few things apparently need to be explicitly stated as far as homework is concerned.

In case things are not mentioned in the homework, the following criteria ALWAYS apply:

  • Code needs to be written using the JDK 8 or better.
  • Code needs to contain the global header information mentioned in the syllabus.  All source code files must have the global header.
  • Code must be formatted properly using Eclipse’s formatting capabilities.
  • Code must use methods and classes to separate the logic. (To be done soon)
  • Always email me gists of your source code.
  • No homework will be accepted after due date and time.  Submit your homework on time.

Exam #1 Friday, September 27

Let’s have our first exam covering chapters 1 and 2 on Friday, Sept. 27.  It will be an in class exam.

CLOSED BOOK/CLOSED NOTES.  COME EARLY TO CLASS AND BRING A PENCIL.

Go here for sample quizzes:

https://media.pearsoncmg.com/ph/esm/ecs_liang_ijp_11/cw/

Even though we didn’t go into too much detail in Chapter 1, that material is essentially Computer Concepts and is something you should already know.  If you don’t know it, study it!

CSC-111 Homework 1

Due Friday, Sept 13  11:59pm.

Solution:

Solution to the Population Problem 1-11  or Solution to the Population Problem 1-11 With Variables

This problem is on page 31 in the textbook.

prob1-11

Do this problem without using variables, loops, or anything beyond what is discussed in Chapter 1. You’ll have a better appreciation for these advanced tools once you do the problem without them.

You need to submit a gist link to silvestri@stcc.edu of your code by the due date and time.