COP2253 Zybooks Chapter One Flashcards
program
consists of instructions executing one at a time
basic instruction types:
input, process, output
input
a program gets data from somewhere
process
a program performs computations on that data, such as adding two values
output
a program puts that data somewhere
variables
used by a program to refer to data
computational thinking
creating a sequence of instructions to solve a problem
algorithm
a sequence of instructions that solves a problem
a program starts in
main(), executing the statements within main’s braces{}, one at a time
each statement typically appears alone on a line and ends with a
semicolon ;
what code at the top of a file enables the program to get input?
import java.util.Scanner;
scanner
a text parser that can get numbers, words, or phrases from an input source such as the keyboard
what statement creates a Scanner object?
Scanner scnr = new Scanner (System.in);
the following statement gets an input value and assigns x with that value:
x = scnr.nextInt();
outputting text is achieved via:
System.out.print(“desired text”);
text in double quotes is known as a
string literal
outputting text with a newline after the outputted values is achieved via:
System.out.println(“desired text”);
outputting a variable’s value is achieved via:
System.out.print(x);
note that no quotes surround x