AP Computer Science Lesson Introductory Java Language Features (4)

in #education7 years ago

Hey Steemers! Enjoy another Java lesson! Learn much...

APCSLogo.png


Quiz 3

True/False:
____ 1. There are 36 bits in 4 bytes.
____ 2. Multiprogramming and multithreading are similar, but multiprogramming allows a computer to run multiple programs at the same time.
____ 3. CD-RW is a rewritable form of a Compact Disc (CD).
____ 4. An integer can have the type double in Java.
____ 5. System.out.println(Hello World); will print Hello World in the command prompt.
____ 6. To start a program declare the class in the first line and the second line is: public static void main(string[] args) {
____ 7. Assembly Language is a computer’s native language, also known as binary.
____ 8. A computer’s components are connected by a subsystem called a bus. The bus sends information from one hardware to another.

Practical:
Write a code that finds the area of a trapezoid with the given values. The formula and values:


Class Practice

  • Write a program that will ask the user for the length, width, and height of a building, then print the volume.

import util.java.Scanner;
public Class AreaTrapezoid {
public static void main(string[] args) {
Scanner length = new Scanner(System.in);
double l = length.nextDouble();
Scanner width = new Scanner(System.in);
double w = width.nextDouble();
Scanner height = new Scanner(System.in);
double h = height.nextDouble();
double volume;
volume = lengthwidthheight;
System.out.println("The volume is: " + volume);
}
}

  • Write a program that prints and solves the following simplification problem:

public Class MathsRock {
public static void main(string[] args) {
int a;
int b;
int c;
a = 25
b = 42
c = -23
Sysyem.out.println(abb/c/c/c);
// You could also use: Sysyem.out.println(abb/(ccc));
}
}

  • Write a program that will give the user multiples of x (given by the user) up to 999. Use a for loop.

import util.java.Scanner;
public Class MultiplesOfX {
public static void main(string[] args) {
System.out.println("What number would you like multiples of?");
Scanner number = new Scanner(System.in);
int multiples = number.nextInt();
int i = 1;
while (multiples < 1000) {
multiples = multiples*i;
System.out.println(multiples);
i = i + 1;
}
}
}

  • Homework:
  1. Write a program that asks a user for their height (in feet). If they type a number less than 2 or a number higher than 10 feet, print "Can't be!". If they type a number between 2 and 10, print "Thank you!". If they type anything else, print "Sorry!".
  2. Write a program that will ask a user for a number, then will print the powers of that number up to 10, for example:

Thank you for your attention Steemites! Hope all is well! Teach your kids!

ColorGIF.gif

Sort:  

nice post man, but i don't know anything about this... have a good weekend, peace (-:

Thanks for the comment silverdad! Hope all is well!

Coin Marketplace

STEEM 0.30
TRX 0.33
JST 0.052
BTC 100146.20
ETH 3986.27
SBD 4.00