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!

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.

HW2 – List the Missing Numbers

DUE: Friday, Sept 20 11:59pm

A data scientist had two lists that were permutations of one another. Unfortunately, while uploading them from one computer to another to another, some numbers were lost out of the first list. Find the missing numbers.

As an example, consider the array with some numbers missing, arr = [7,2,5,3,5,3], and the original array of numbers brr=[7,2,5,4,6,3,5,3]. The numbers missing are [4,6] .

Notes

  • If a number occurs multiple times in the lists, you must ensure that the frequency of that number in both lists is the same. If that is not the case, then it is also a missing number.
  • You have to print all the missing numbers in ascending order.
  • Print each missing number once, even if it is missing multiple times.

Function Description

Create a missingNumbers function. It should return a sorted array of missing numbers. missingNumbers has the following parameter(s):

  • arr: the array with missing numbers
  • brr: the original array of numbers

Input Format

There will be four lines of input:

  • n – the size of the first list, arr
  • The next line contains n space-separated integers arr[i]
  • m – the size of the second list
  • The next line contains m space-separated integers brr[i]

Output Format

Output the missing numbers in ascending order.

Sample Input

10
203 204 205 206 207 208 203 204 205 206
13
203 204 204 205 206 207 205 208 203 206 205 206 204

Sample Output

204 205 206

Test your code by entering the examples given above using the keyboard. Once you believe the code is correct, modify the code to read a file. Download this following file, place it in your project, and run your code on the file:

You are probably going to need to use linear searching in this app, so be sure to download and add the Ultimate Linear Search Class to your project.

Use the Template.

Sample Code

How to return an array of unknown size:

import java.util.Arrays;

public class SampleCode {
  private static int[]generateJunk(int count) {
    int values[] = new int[count];
    for (int i = 0; i < values.length; i++) 
      values[i] = (int) (Math.random() * 100) + 1;	
    return values;
  }
  
  private static int[] multiplesOfN(int[] arr, int n) {
    int values[] = new int[arr.length];
    int count = 0;
    for (int i = 0; i < arr.length; i++) {
      if (arr[i] % n == 0) 
	values[count++] = arr[i];
    }
    return Arrays.copyOf(values, count);
  }

  public static void main(String[] args) {
    int junk[] = generateJunk(100);
    int multiples[] = multiplesOfN(junk, 7);
    System.out.println(Arrays.toString(multiples));
  }
}

How to read a file: (Unfortunately you need global variables to return more than 1 array based on what we know now. We’ll fix that problem later in the semester.)

import java.io.File;
import java.util.Arrays;
import java.util.Scanner;

public class SampleCode {
  private static int arr[];
  private static int brr[];

  private static void readFile(Scanner sc) {
    try {
      System.out.print("Enter Filename: ");
      String filename = sc.nextLine();
      Scanner fileInput = new Scanner(new File(filename));
      int aSize = fileInput.nextInt();
      arr = new int[aSize];
      for (int i = 0; i < arr.length; i++)
	arr[i] = fileInput.nextInt();
      int bSize = fileInput.nextInt();
      brr = new int[bSize];
      for (int i = 0; i < brr.length; i++)
	brr[i] = fileInput.nextInt();
      fileInput.close();
    } 
    catch (Exception ex) {
    }
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    readFile(sc);
    System.out.println(Arrays.toString(arr));
    System.out.println(Arrays.toString(brr));
}

CSC-111 HW2 Calculate Temperature, Dewpoint, or Relative Humidity

Due: Friday, Sept 20, 11:59pm

Create a program that inputs the 3 sets of 2 inputs needed to calculate Actual Temperature, Dewpoint, and Relative Humidity. For instance, entering Actual Temperature and Dewpoint will calculate the corresponding Relative Humidity. Entering Actual Temperature and Relative Humidity, calculates Dewpoint. Finally, entering Dewpoint and Relative Humidity, allows calculation of Actual Temperature.

Use the Scanner class for your input. To be clear, you will submit just one program that will have a total of 6 input methods and 3 calculations and outputs.

Use this website: http://andrew.rsmas.miami.edu/bmcnoldy/Humidity.html for the necessary formulas. That page also has a calculator, you can use to check your own calculations.

All the temperatures in the equations are based in Celcius.  We live in a Fahrenheit world.  Please input and output temperatures in Fahrenheit.

Your outputs should be neatly formatted and annotated. Output 3 decimal digits.

Note: Just use the topics discussed in chapter 2, or what was discussed in class.  No methods, loops, if statements should be coded.

Hint:

References in the formulas to

  • exp(expr) is Math.exp(expr) in Java
  • ln(expr) is Math.log(expr) in Java

CSC-220 Chapter 7 Searching and Sorting Examples

Sorting and Searching V1:
http://pastebin.com/Mrryf839

Sorting and Searching V2 using Arrays methods:
http://pastebin.com/Sk7e5GtX

Sorting Using BinarySearch routine (updated 9/17/18):
https://gist.github.com/bytecodeman/2375a479f829025dfe643b2c785a65fc

String Sorting:
http://pastebin.com/D57LPbB9

String Sorting V2 With Interfaces and Lambdas
https://pastebin.com/pV1sgRq8

Sherlock Holmes and the Beast (In class method challenge)

Solution: https://gist.github.com/bytecodeman/8e838d5f7c0e88af2f2b96c8aebf56ac

Sherlock Holmes suspects his archenemy Professor Moriarty is once again plotting something diabolical. Sherlock’s companion, Dr. Watson, suggests Moriarty may be responsible for MI6’s recent issues with their supercomputer, The Beast.

Shortly after resolving to investigate, Sherlock receives a note from
Moriarty boasting about infecting The Beast with a virus. He also
gives him a clue: an integer. Sherlock determines the key to removing
the virus is to find the largest Decent Number having that number of
digits.

A Decent Number has the following properties:

  1. Its digits can only be 3’s and/or 5’s.
  2. The number of 3’s it contains is divisible by 5.
  3. The number of 5’s it contains is divisible by 3.
  4. It is the largest such number for its length.

Moriarty’s virus shows a clock counting down to /The Beast/’s
destruction, and time is running out fast. Your task is to help Sherlock
find the key before The Beast is destroyed!

For example, the numbers 55533333 and 555555 are both decent numbers because there are 3 5’s and 5 3’s in the first, and 6 5’s in the second. They are the largest values for those length numbers that have proper divisibility of digit occurrences.

Function Description

Create a the decentNumber function in our class template. Function takes as input number of digits in decency. It should return a String of the numbers for the given length, or -1 if a decent number of that length cannot be formed.

In the template prompt for the number of digits in the decent Number, call the function, and output its result.

Sample Input

Input: 1
Output: -1

Input: 3
Output: 555

Input 5
Output: 33333

Input 11
Output: 55555533333

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.

Download and Use JDK 10.0.2!!!

Link to: https://cs.stcc.edu/getting-familiar-with-linux-for-java-programmers/

Don’t use the latest Java 11. For whatever reason, Oracle decided to not bundle JavaFX with it.

If you really what to use Java 11, you’ll need to download and install JavaFX separately. I’ll leave you to google the instructions on how to do that.

Use JDK 10.0.2. It has JavaFX built in and is what is installed in our labs.

If you already installed Java 11, uninstall it entirely.  

Download JDK 10.0.2. Since Oracle is pushing the latest and greatest Java 11, you’ll need to jump through some hoops to get it. Here’s how:

  • Go to the JDK download page.
  • At the bottom of the page, there’s a Java Archive.  Click that.
  • Select Java SE 10
  • You may need to create an account to download it. Go ahead; it’s safe.

You’ll have a much better JavaFX experience!

Good Luck

CSC-220 HW1 (Twin Primes)

Let’s do problem 6.29 (Twin Primes) shown here:

DUE: Friday, Sept 13 11:59pm

Solution: https://gist.github.com/bytecodeman/95c989a4f1bfe9e1d892d5720864b75e

Slight Modification on Specs: Have user enter starting and end point ranges for the twin primes. Don’t just return twins < 1000; that would be boring.

Here is a gist of the solution to 6.26 discussed in class:
https://gist.github.com/bytecodeman/3413b5197a7663b0eee742aa144cdda2

Incorporate the Project Template for those writing a command line program.  CSC-112 graduates can write a GUI to do this problem for extra credit.  Don’t forget that knowledge. 

The template provides a way to run the code over and over again without having to restart the program.  For each run, prompt for the starting point for the emirp analysis and how many emirps you want to find from that starting point.

MyMathLab Course IDs


MAT-078-E53 Pre-Algebra Fall 2019 W 6pm
Course ID: silvestri75487

MAT-087-D03 Algebra 1 Fall 2019 MWF 9:05am
Course ID: silvestri65402

MAT-087-D14 Algebra 1 Fall 2019 TTh 9:30am
Course ID: silvestri24514

If you have already taken Algebra 1 here at STCC and used the Pearson system, use the Pearson account you already have and register with the course id. You may not even have to purchase another course code id!

Supplemental Instruction (SI)

Introducing Jimmy Alvarez, Java Certified Programmer. We are lucky to have his services as a Supplemental Instructor for all Java courses running this Fall 2019 semester.

The college has a new program called Supplemental Instruction (SI). Through this program, you will have the opportunity to meet weekly with our SI Leader, who will provide weekly review sessions for all interested students. The Leader is a current student who has recently taken the course and done well. They will be in class with you every day, hearing what you hear, and reading what you read. During each review session, you will have a chance to get together with your classmates to compare notes, discuss concepts that might be confusing, review material for tests and quizzes, and ask any questions that you might have.

Sessions will begin the week of September 8th, and run through the end of the semester. You can attend as many review sessions as you like; each one will be different because you will have new material to discuss. SI sessions are informal – bring any notes you have, your textbook, or a classmate! By coming to these sessions, you will be able to develop a better understanding of the course content as well as more effective ways of learning.

If you are unable to attend the group session, but would like to meet with the SI Leader, you can set up an individual time to meet with them. You can let them know you would like to make an appointment with them when you see them in class, or feel free to send them a note through their college email.

I am thrilled that we have this new opportunity for you, and I am hopeful that you take advantage of this program.

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.

Links and Resources for Java Courses

Liang 11th Edition Resources

Common Resources

Math – Silvestri’s Special Apps Center!

Check out:   https://cs.stcc.edu/specialapps/

I have some ideas for apps to add to this website, so please visit every now and then.

If you have an idea for an app that you think would be useful, would benefit a student, or would make the world a better place, please share ( silvestri@stcc.edu ), and if it isn’t too involved, and I have the time, I’ll code the problem and make it a special app.

Welcome to Professor Silvestri’s Math Courses

  • There are math lecture videos based on our textbook.  You can access them here:    Algebra Videos      (This is STCC’s portal website.  You’ll need to login with your Webadvisor credentials.) If you miss a class or need another prospective on the material, give these videos a try.
  • To take these courses, you must have access to a computer as this will be a hybrid lecture / online study course.  We will be using http://www.mymathlab.com/. So you must purchase the Student Access Code package and register using the appropriate Course Code (ID) shown above.
  • (Optional Textbook for Algebra)  Introductory Algebra through Applications, 3rd Edition, Akst and Bragg, 2012, Pearson Education, ISBN: 9780321746696algebratext
  • (Free Textbook)   Bedinelli Pre Algebra TextBook
  • (Free Textbook)  Bedinelli Algebra 1 Textbook
  • (Free Textbook)  Bedinelli Algebra 2 Textbook