GithubHelp home page GithubHelp logo

aynalemfan / arrays-loops-strings Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ocskier/arrays-loops-strings

0.0 0.0 0.0 12 KB

Lesson on Java Arrays, ArrayLists, Loops, Strings

License: Apache License 2.0

Java 100.00%

arrays-loops-strings's Introduction

ArraysLoopsStrings

Lesson on Java Arrays, ArrayLists, Loops, Strings

Directions to Clone and load in IntelliJ

  • Go to this Repo and FORK this repository onto your github
  • Copy the HTTPS URL from the "Code" button on your GH
  • Open your terminal (Git bash) and navigate to the appropriate location where you wish to save the folder to and run
git clone URL-you-Copied-goes-here
  • Open IntelliJ and click on new project

  • Select Java and make sure you have a Project SDK selected and then click next

    • Leave the box for create project from template unchecked and click next
  • Click on three dots ... next to project location. Change project location to the directory you just cloned to your machine. Click OK and then click Finish.

  • MSGrades will be the entry point for your application.

  • Click on the MSGrades java file and read thru the comments.

  • Anytime you want to test the code right click on MSGrades.java the first time and select Build Module which should open the Build output and then clicking the green hammer will compile future rebuilds

  • To run the first time right click on MSGrades.java and click Run MSGrades.main() which will also open the Run output and then on the Green play button will attempt further reruns

Directions for Coding

  • Make all your instance fields private and all your classes and methods public
  • Import the java util ArrayList class module at the top for good practice
  • Create 4 ArrayLists instance variables below the teachers one all private constant(final)
    1. a new instance of a students ArrayList storing strings
    2. a new instance of a math grades ArrayList storing integers
    3. a new instance of a science grades ArrayList storing integers
    4. a new instance of a english grades ArrayList storing integers

  • Inside the class constructor add some students and their grades to the ArrayLists
    1. add two students to the students ArrayList
    2. add two corresponding values for the two students to the math grades ArrayList
    3. add two corresponding values for the two students to the science grades ArrayList
    4. add two corresponding values for the two students to the english grades ArrayList

  • Inside the printStudents public method
    • loop thru the students ArrayList with a For Each loop
      • print each students name on a new line as output

  • Make a method that prints an individual students grades
    • It will be public, not have a return value, and have one int type parameter that is a students index
    • Inside the method:
      • Print the students name by using the index variable to index the students array
      • Print a concatenated string of say "Math: " + and the corresponding grade from that ArrayList of grades by index
      • Do this for the next two subjects
      • Total of four output statements

  • Inside the main function before the first two given output statements
    • create a new instance of MSGrades class and store in a variable (anything like msGrade8)
    • look up how to print an empty new line for readability
  • After
System.out.println("Middle School Roster");
System.out.println("====================");
  • invoke or run the printStudents method on our class instance
  • Print another empty line if desired for readability
  • Use a for loop to loop thru the given teachers array on the class instance
  • inside the loop
    • create a new variable that stores the result of "Teacher: " + teachers name from the array using the counter variable
    • Print the new variable as output
  • After
System.out.println("\nStudent Grades:\n");
  • Use a for loop to loop thru students ArrayList on the class instance
  • inside the loop
    • pass the counter var as an index to the printStudentGrades method to print each students info
    • Print a new line if you want it to look presentable

Directions for Pushing Revision to github

  • Push your changes up to your repository. From your git bash terminal, enter the following commands:
git add .
git commit -m “Adds solutions to activity”
git push -u origin main
  • Go to your GitHub repository. You should see your changes.
  • If you want you can submit a PR to merge changes

If you finish early, consider adding some additional functionality. Be original, add some of your own functionality to the application.

arrays-loops-strings's People

Contributors

ocskier avatar

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.