Guide to Teaching Computer Science by Orit Hazzan Tami Lapidot & Noa Ragonis
Author:Orit Hazzan, Tami Lapidot & Noa Ragonis
Language: eng
Format: epub
Publisher: Springer London, London
import java.util.Scanner;
public class Condition {
public static Scanner input = new Scanner(System.in);
public static void main(String args) {
double num;
System.out.println (“enter number”);
num = input.nextDouble();
System.out.println (“good number”);
System.out.println (“end”);
}
}
Task 1, Part A
Open a new class and type the class presented on the left.
Save it, run it, check its output and write it down.
import java.util.Scanner;
public class Condition {
public static Scanner input = new Scanner(System.in);
public static void main(String args) {
double num;
System.out.println (“enter number”);
num = input.nextDouble();
if (num > 0)
System.out.println (“good number”);
System.out.println (“end”);
}
}
Task 1, Part B
We now change the class so that the message “good number” is printed only if the variable num is positive.
Change the class according to the code on the left.
Save it and run it.
When the program waits for an input, type a positive number.
The output is: ________________________
Run it again. This time, when the program waits for an input, type a negative number.
The output is: ________________________
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Administration | Assessment |
Educational Psychology | Experimental Methods |
History | Language Experience Approach |
Philosophy & Social Aspects | Reform & Policy |
Research |
The Art of Coaching Workbook by Elena Aguilar(50036)
Trainspotting by Irvine Welsh(20940)
Twilight of the Idols With the Antichrist and Ecce Homo by Friedrich Nietzsche(18266)
Fangirl by Rainbow Rowell(8753)
Periodization Training for Sports by Tudor Bompa(7887)
Change Your Questions, Change Your Life by Marilee Adams(7317)
This Is How You Lose Her by Junot Diaz(6401)
Asking the Right Questions: A Guide to Critical Thinking by M. Neil Browne & Stuart M. Keeley(5317)
Grit by Angela Duckworth(5261)
Red Sparrow by Jason Matthews(5165)
Paper Towns by Green John(4751)
Room 212 by Kate Stewart(4703)
Ken Follett - World without end by Ken Follett(4410)
The Sports Rules Book by Human Kinetics(4041)
Housekeeping by Marilynne Robinson(4015)
Double Down (Diary of a Wimpy Kid Book 11) by Jeff Kinney(3873)
Papillon (English) by Henri Charrière(3870)
The Motorcycle Diaries by Ernesto Che Guevara(3754)
Exercise Technique Manual for Resistance Training by National Strength & Conditioning Association(3754)
