GithubHelp home page GithubHelp logo

javaproblemswithsoftware's Introduction

Java Programming: Solving Problems with Software

The assignments from Java Programming: Solving Problems with Software on Coursera

Solving Programming Problems: A Seven Step Approach

  1. Work Example By Hand
  • Solve small instance by hand
  • Unclear problem?
  • Need domain knowledge?
  1. Write Down What You Did
  • Write down exact steps
  • Just that instance
  • Tricky: do without thinking
  1. Find Patterns
  • Algorithm for any instance
  • Find patterns
  • Repetition, conditions, values
  • Difficulties?
    • Try step 1 + 2 again
    • Different inputs
  1. Check By Hand
  • Incorrect pattern? Find now
  • Check with different inputs
  1. Translating To Code
  • Programming language
  1. Run Test Cases
  • Run test cases on code
  • Check anwser
  1. Debug Failed Test Cases
  • Test failed? Debug
    • Use scientific method
    • Understand problem + fix
  • Algorithm problem?
    • Return to step 3 and fix the algorithm
  • Implementation problem?
    • Return to step 5 and correct the translation of the algorithm to code

Assignments:

Week 1: Iterables in Java

Assignment 1: Batch Grayscale
Assignment 2: Image Inversion

Week 2: Strings in Java

Assignment 3: Finding a Gene
Assignment 4: Finding Web Links
Assignment 5: Finding All Genes
Assignemnt 6: Storing All Genes / Processing DNA Strings
Assignment 7: Find All URLs

Week 3: CSV Files and Basic Statistics in Java

Assignment 8: Parsing Export Data
Assignment 9: Parsing Weather Data

The mini project helps find out what name this year has the same popularity rank as your name did the year you were born based on processing the CSV data files of the popularity of baby names from the United States.

javaproblemswithsoftware's People

Contributors

akueisara avatar imgbot[bot] avatar

Stargazers

 avatar Mohammed Hasanul Chowdhury avatar Steve Fisher avatar  avatar Vaibhav More avatar tektology avatar

Watchers

James Cloos avatar  avatar Jonathan Cabrera avatar Dhivya R avatar

javaproblemswithsoftware's Issues

hey, i have a question for you

My question is your getrank method, what if two different names have same number of appearance on that year?For example: Mason 7, Ethan 7

Wrong output for "fileWithColdestTemperature" in ParsingWeatherData.java

Hey man... first of all, massive thanks for making this repo, it helped me out alot.

I noticed a small mistake in your code.

File: ParsingWeatherData.java
Method: fileWithColdestTemperature

public static String fileWithColdestTemperature() {
		CSVRecord coldestSoFar = null;
		String filename="";
		
		DirectoryResource dr = new DirectoryResource();
		for( File f : dr.selectedFiles()){
			FileResource fr = new FileResource(f);
			CSVParser parse = fr.getCSVParser();
			CSVRecord currentRecord = coldestHourInFile(parse);
			coldestSoFar = getSmallestOfTwo(currentRecord, coldestSoFar);
			filename = f.getPath(); // the mistake is right here...
		}
		return filename;
	}

So, what happens is that you parse through all the files, and successfully find the coldest hour, but your filename is still getting updated again and again, even when you don't find any more colder temps... so if you parse through 2014, you end up getting filepath for December 31st, 2014.... which is wrong...

Here's my suggestion/solution:

    public String fileWithColdestTemperature ()
    {
        String nameOfFile = "";
        CSVRecord smallestSoFar = null;
        DirectoryResource dr = new DirectoryResource();

        for(File f: dr.selectedFiles())
        {
            FileResource fr = new FileResource(f);
            CSVParser parse = fr.getCSVParser();
            CSVRecord currentRow = coldestHourInFile(parse);
            
            if(smallestSoFar == null)
            {
                smallestSoFar = currentRow;
                nameOfFile = f.getAbsolutePath();
            }
            else
            {
                double currentTemp = Double.parseDouble(currentRow.get("TemperatureF"));
                double smallestTemp = Double.parseDouble(smallestSoFar.get("TemperatureF"));
                if((currentTemp < smallestTemp) && (currentTemp > -90)) //... ignoring bogus values...lowest temp ever recorded on Earth was -89.2...
                {
                    smallestSoFar = currentRow;
                    nameOfFile = f.getAbsolutePath(); //... point of interest
                }
            }
        }
        return nameOfFile;
    }

So, as you see, I only update filepath when i update coldest temperature... hope this helps. have fun ๐Ÿ‘

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.