Computing Adjusted Quiz Total Score

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

EXAMPLES (Arrays). Example Many engineering and scientific applications represent data as a 2-dimensional grid of values; say brightness of pixels in.
Introduction to Computer Science Robert Sedgewick and Kevin Wayne Recursive Factorial Demo pubic class Factorial {
Picture It Very Basic Game Picture Pepper. Original Game import java.util.Scanner; public class Game { public static void main() { Scanner scan=new Scanner(System.in);
Problem Solving 5 Using Java API for Searching and Sorting Applications ICS-201 Introduction to Computing II Semester 071.
Session 3 Algorithm. Algorithm Algorithm is a set of steps that are performed to solve a problem. The example below describes an algorithm Example Check.
Introduction to Computer Programming Decisions If/Else Booleans.
1 Algorithms and Problem Solving. 2 Outline  Problem Solving  Problem Solving Strategy  Algorithms  Sequential Statements  Examples.
Lecture 7. Review Homework 1 (sample solution) Project 1 will be assigned next week –Draw a picture (whatever you want) in the world by using turtles.
Writing algorithms using the for-statement. Programming example 1: find all divisors of a number We have seen a program using a while-statement to solve.
Computer Programming Lab(4).
Shorthand operators.
Methods and You. Up to this point, I have covered many different data types with you. Variables can be considered the nouns of an English sentence. If.
Introduction to Computer Programming Counting Loops.
1 BUILDING JAVA PROGRAMS CHAPTER 2 PRIMITIVE DATA AND DEFINITE LOOPS.
Recursive. 2 Recursive Definitions In a recursive definition, an object is defined in terms of itself. We can recursively define sequences, functions.
Computer Programming 12 Mr. Jean April 24, The plan: Video clip of the day Upcoming Quiz Sample arrays Using arrays More about arrays.
Mixing integer and floating point numbers in an arithmetic operation.
The assignment expressions. The assignment operator in an assignment statement We have seen the assignment statement: Effect: var = expr; Stores the value.
Take out a piece of paper and PEN. The quiz starts ONE minute after the tardy bell rings. You will have 45 – 90 seconds per question. Determine the output.
FOR LOOP WALK THROUGH public class NestedFor { public static void main(String [] args) { for (int i = 1; i
Cumulative algorithms. 2 Adding many numbers How would you find the sum of all integers from ? // This may require a lot of typing int sum = 1 +
Introduction to array: why use arrays ?. Motivational example Problem: Write a program that reads in and stores away 5 double numbers After reading in.
AD Lecture #1 Object Oriented Programming Three Main Principles 1 Inheritance Encapsulation Polymorphism.
Creating Web Services Presented by Ashraf Memon Presented by Ashraf Memon.
Boolean expressions, part 1: Compare operators. Compare operators Compare operators compare 2 numerical values and return a Boolean (logical) value A.
The ++ and -- expressions. The ++ and -- operators You guessed it: The ++ and -- are operators that return a value.
Print Row Function void PrintRow(float x[ ][4],int i) { int j; for(j=0;j
Methods.
AP Computer Science A – Healdsburg High School 1 Unit 9 - Parameter Passing in Java.
Chapter 8 Slides from GaddisText Arrays of more than 1 dimension.
import java.util.Scanner; class myCode { public static void main(String[] args) { Scanner input= new Scanner(System.in); int num1; System.out.println(“Enter.
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
Adding, Subtracting, Multiplying, and Dividing Rational Numbers.
JAVA METHODS (FUNCTIONS). Why are they called methods? Java is a strictly object-oriented programming language Methods are functions inside of objects.
Building Java Programs Chapter 4 Lecture 4-1: Scanner ; cumulative algorithms reading: 3.3 – 3.4, 4.2.
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
Methods. Creating your own methods Java allows you to create custom methods inside its main body. public class Test { // insert your own methods right.
UFCFY5-30-1Multimedia Studio Coding for Interactive Media Fundamental Concepts.
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
Department of Computer Science
Algorithms and programming
using System; namespace Demo01 { class Program
USING ECLIPSE TO CREATE HELLO WORLD
RADE new features via JAVA
Computer Programming Methodology Input and While Loop
Function Call Trace public class Newton {
Something about Java Introduction to Problem Solving and Programming 1.
Building Java Programs
Writing Methods.
Chapter 8 Slides from GaddisText
Code Animation Examples
Method Overloading in JAVA
Recursive GCD Demo public class Euclid {
Take out a piece of paper and PEN.
References and Objects
class PrintOnetoTen { public static void main(String args[]) {
Java Programming with Multiple Classes
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
Methods and Data Passing
Scope of variables class scopeofvars {
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
Developing Java Applications with NetBeans
Developing Java Applications with NetBeans
Building Java Programs
Lecture 22: Number Systems
6.2 for Loops Example: for ( int i = 1; i
Data Structures and Algorithms 2/2561
CPSC 233 Tutorial 13 March 11/12th, 2015.
Presentation transcript:

Computing Adjusted Quiz Total Score

Main Algorithm Get 12 quiz scores Get 12 adjustment values Compute 12 adjusted scores by adding the corresponding adjustment value to each score Compute the sum of the two lowest adjusted scores Compute the sum of the 12 adjusted scores Compute the total adjusted quiz score by subtracting the sum of the two lowest adjusted scores from the sum of the 12 adjusted scores Print the total adjusted quiz score

Java Code public class TotalAdjustedQuizScore { public static void main(String[] args) { // Get 12 quiz scores // Get 12 adjustment values // Compute 12 adjusted scores by adding the // corresponding adjustment value to each score // Compute the sum of the two lowest adjusted scores // Compute the sum of the 12 adjusted scores // Compute the total quiz score by subtracting the // sum of the two lowest adjusted scores from the sum // of the 12 adjusted scores // Print the total quiz score } }

Java Code Expanded public class TotalAdjustedQuizScore { public static void main(String[] args) { // Get 12 quiz scores int[] score = {7, 6, 10, 9, 5, 4, 6, 7, 8, 5, 0, 8}; // Get 12 adjustment values int[] adjustmentValue = {1, 2, 0, 0, 0, 2, 1, 0, 2, 1, 0, 1}; // Compute 12 adjusted scores by adding the // corresponding adjustment value to each score int [] adjustedScore = addArrays(score,adjustmentValue,12);

Java Code Expanded (Cont’d) // Compute the sum of the two lowest adjusted scores int sumTwoLowest = getSumOfTwoLowestElements(adjustedScore,12); // Compute the sum of the 12 adjusted scores int sumAdjustedScores = getSumOfArrayElements(adjustedScore,12); // Compute the total quiz score by subtracting the // sum of the two lowest adjusted scores from the sum // of the 12 adjusted scores int totalAdjustedScore = sumAdjustedScore - sumTwoLowest; // Print the total quiz score System.out.println("Total Adjusted Quiz Score = " + totalAdjustedScore); }

Java Code Expanded (Cont’d) public static int[] addArrays(int[] a, int[] b, int n) { int[] c = {9,10,10,9,5,6,7,7,10,6,0,9}; return c; } public static int getSumOfTwoLowestElements(int[] a, int n) { return 5; } public static int getSumOfArrayElements(int[] a, int n) { return 85; } }