Object Oriented Programming with Java
ToledoSlackGitHub Org 1GitHub Org 2
Primary version
Primary version
  • About this Course
  • Introduction to Computer Programming
    • Introduction to Computer Programming
    • Challenges
    • Multiple Choice
  • Basic Building Blocks
    • Basic Building Blocks
    • Challenges
    • Multiple Choice
  • Starting in Java
    • Starting in Java
    • Challenges
    • Multiple Choice
  • Storing and Processing Data
    • Storing and Processing Data
    • Challenges
    • Multiple Choice
  • Making Decisions
    • Making Decisions
    • Challenges
    • Test Yourself
    • Multiple Choice
  • Loop Constructs
    • Loop Constructs
    • Challenges
    • Multiple Choice
  • Strings
    • Strings
    • Challenges
    • Multiple Choice
  • Arrays
    • Arrays
    • Challenges
    • Multiple Choice
  • Object Oriented Thinking
    • Object Oriented Thinking
  • All About Objects
    • All About Objects
    • Multiple Choice
  • Defining Classes
    • Defining Classes
    • Challenges
    • Multiple Choice
  • Methods
    • Methods
    • Challenges
    • Multiple Choice
  • Constructors
    • Constructors
    • Multiple Choice
  • Inheritance
    • Inheritance
  • Starting with JavaFX
    • Starting with JavaFX
  • Hands On
    • Hands on MQTT
    • Hands on GSON
  • Hack @ IT
    • Hack @ IT
    • Caesar Encryption
      • Solution
    • Complex Numbers
  • Assignments
    • Number Characteristics
    • Linear Equation
    • LineSegment
  • Videos
    • Videos
  • Sources
    • Sources
Powered by GitBook
On this page
  • Chapter 04 - Storing and processing data - Challenges
  • Data Types
  • Basic Division
  • Floating Point Division
  • Remainder
  • Calculating VAT
  • Rectangle Area
  • String Concatenation
  • Circle Properties
  • Concatenation and Addition
  1. Storing and Processing Data

Challenges

Chapter 04 - Storing and processing data - Challenges

Data Types

In the most left column is a piece of data that is stored inside of the computers memory. What would be a possible data type for each piece of information? In some cases multiple data types would be valid.

Data

int

double

boolean

char

String

128

[]

[]

[]

[]

[]

-12

[]

[]

[]

[]

[]

a

[]

[]

[]

[]

[]

Hello World

[]

[]

[]

[]

[]

108.6

[]

[]

[]

[]

[]

true

[]

[]

[]

[]

[]

Spoorwegstraat 12, 8200 Brugge

[]

[]

[]

[]

[]

A

[]

[]

[]

[]

[]

0471 11 18 23

[]

[]

[]

[]

[]

3.14

[]

[]

[]

[]

[]

x

[]

[]

[]

[]

[]

ZZ Top

[]

[]

[]

[]

[]

false

[]

[]

[]

[]

[]

-778.81323

[]

[]

[]

[]

[]

Basic Division

Determine the result of 2 divided by 3. Next try out 2.0 divided by 3.

Floating Point Division

Take the code below and execute it:

int a = 5;
int b = 2;

double result = a / b;

How can you change only the last line to get a result of 2.5?

Remainder

What is the remainder of 8759 divided by 33?

Calculating VAT

When buying a product in the store you always need to pay VAT (taxes). Take for example a pair of shoes that costs 100eur net, you actually pay 121eur.

Write a program that calculates how much the total bill would be if the net amount is 250eur.

Rectangle Area

Determine the area of a rectangle with a side of 2.3cm and a side of 8.2cm. Make your program outputs a decent result to the user.

String Concatenation

Take the code below and change the variable fullText to contain all partial strings before it.

String hello = "Hello sir/madam on this fine day of learning.";
String hackerspace = "I would like to inform you that there will be hackerspace on tuesdays and thursdays.";
String attend = "Feel free to attend it as it will be fun for all.";

String fullText;

Print out the variable fullText so the whole message is shown to the user.

Circle Properties

Write a Java program to determine the area and circumference of a circle. They can be calculated using the formulas below:

area = radius x radius x pi
circumference = 2 x radius x pi

Make sure all the variables are of type double.

Print all the parameters to the terminal (radius, diameter, area and circumference) so the user had a nice overview. For example:

Hello and welcome to the Circle Properties app.

Properties of circle:
- radius: 2.15 meters
- diameter: 4.30 meters
- circumference: 13.51 meters
- area: 14.52 square meters

Thank you for using the app.

You can create a variable to hold an approximation to the value of pi. However, Java can supply a more accurate version of PI. Can you find on the Internet how to access/use this value?

Concatenation and Addition

Explain the difference in output between the following two lines of code:

System.out.println("Berekening 1: " + 12 + 88);
System.out.println("Berekening 2: " + (12 + 88));
PreviousStoring and Processing DataNextMultiple Choice

Last updated 6 years ago