import java.util. Scanner; Conditionals warmup Assignment For use with the GTCs
ID: 3924391 • Letter: I
Question
import java.util. Scanner; Conditionals warmup Assignment For use with the GTCs (Game-Themed computer Science) Conditionals Module * Authors: Rob Nash, et al Last Modified Date: 1/18/2016 Purpose of this program: This is meant to test your understanding of the following structures in Java: a) The Single If b) Multiple, Back-to-back sequential If Statements (not joined, so mutually exclusive) O) The IF/Else * d) The Multi-Way IF/Else with Tail Test e) The Multi-Way If/Else with Default or catch-All Tail else * F) The Switch * You should also exercise your understanding of console IO by using Scanner to prompt the * user for the following exercises below public class conditional swarmup { * This is an example method header . Notice how it's multi-line and written using college-level English * and not fragments - this is for the Human to read and not the compiler to parse, so be verbose here. * The purpose of this main method is to give you a starting point for this assignment . Extend the code below and * add the exercises as specified in the assignment . You should be exercising the outcomes as they are defined * in the file header above, and should practice each one until you are confident in your branching abilities. * Notice that you'll have to fix some errors in the pseudocode below to get this to compile, just like your * first lab. public static void main(String) args) { Scanner keyboard - new ScannerCsystem, in); /use this to set up variables below, such as "number ", "average ", etc . MINSTODO 1 System.out.printinC"Enter the number for TOD0 1"); int number - keyboard.nextInt; if the number is negative > you must fix this pseudocode before you can compile it System.out.printinC"The number is negative"); STODO 2 number - ? M/we need a new number here for this todoExplanation / Answer
Hello could you please clarify the TODO 11 and 15.I have so doubt regarding that.Could you please eloborate those two.So that I can complete those two also so that which will meet your EXACT requirement .Thank You.
ConditionalsWarmup.java
import java.util.Scanner;
public class ConditionalsWarmup {
public static void main(String[] args) {
Scanner keyboard=new Scanner(System.in);
//TODO 1
System.out.print("Enter the number for TODO 1:");
int number=keyboard.nextInt();
if(number<0)
System.out.println(":: The Number is negative ::");
//TODO 2
System.out.print("Enter a Second number :");
number=keyboard.nextInt();
if(number==0)
System.out.println(":: The Number is Zero ::");
//TODO 3
double average;
System.out.println(":: Enter a double for the class Average ::");
average=keyboard.nextDouble();
if(average>=65.0)
System.out.println(":: A Passing Grade ::");
else if(average<65.0)
System.out.println(":: Average is below 65.0 ::");
//TODO 4 and TODO 5
boolean answer;
System.out.print("Enter a Boolean value: ");
answer=keyboard.nextBoolean();
if(answer==true)
System.out.println(":: The value was true ::");
else
System.out.println(":: The value was false ::");
//TODO 6
System.out.print("Enter a number :");
number=keyboard.nextInt();
if(number%2==0)
System.out.println(":: The Number is Even ::");
else
System.out.println(":: The Number is odd ::");
//TODO 7
float grade=0.0f;
grade=keyboard.nextFloat();
if(grade>89.5f)
System.out.println(":: The grade is an A ::");
//TODO 8
else if(grade>83.49 && grade<90)
System.out.println(":: The grade is B ::");
else if(grade>75.0 && grade<83.49)
System.out.println(":: The grade is C ::");
System.out.println(":: The grade is B ::");
//TODO 9
int temperature=0;
System.out.print("Enter the Temperature :");
temperature=keyboard.nextInt();
if(temperature>78)
System.out.println(":: Current Temperature is Higher than 78 degrees ::");
else if(temperature<=78)
System.out.println(":: Current Temperature is Less than or equal to degrees ::");
//TODO 10
System.out.print("Enter a number :");
number=keyboard.nextInt();
if((number>0 && number%2!=0) || number==0 || (number<0 && number%2==0))
System.out.println("The number is either positive and odd,Zero,or negative and even :");
else
System.out.println("The number is must be positive and even ,or negative and odd :");
//TODO 11
char lettergrade=0;
System.out.print("Enter a Letter Grade :");
lettergrade=keyboard.next(".").charAt(0);
//TODO 12
int maximum,x,y;
System.out.print("Enter First Number :");
x=keyboard.nextInt();
System.out.print("Enter Second Number :");
y=keyboard.nextInt();
maximum=max(x,y);
System.out.println("The Maximum of two numbers is :"+maximum);
if(x>y)
System.out.println(":: "+x+" was larger than "+y+" ::");
else if(x<y)
System.out.println(":: "+y+" was larger than "+x+" ::");
else if(x==y)
System.out.println(":: "+x+" is Equal to "+x+" ::");
//TODO 15
lettergrade=keyboard.next(".").charAt(0);
switch(lettergrade)
{
}
}
private static int max(int a, int b) {
int max=0;
if(a>b)
max=a;
else
max=b;
return max;
}
}
______________________________________
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.