This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A different approach to the Grades and Points exercize from University of Helsinki’s Java Programming I | |
// https://java-programming.mooc.fi/part-1/6-conditional-statements | |
//Programming exercise: | |
// Grades and Points | |
// Points | |
// 1/1 | |
// | |
// The table below describes how the grade for a particular course is determined. | |
// Write a program that gives a course grade according to the provided table. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ByteShortIntLong { | |
public static void main(String[] args) { | |
byte myMinByteValue = Byte.MIN_VALUE; | |
byte myMaxByteValue = Byte.MAX_VALUE; | |
System.out.println("8 Bit Byte Minimum Value = " + myMinByteValue); | |
System.out.println("8 Bit Byte Maximum Value = " + myMaxByteValue); | |
short myMinShortValue = Short.MIN_VALUE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
We use the integers a, b, and n to create the following series: | |
(a + 2⁰ · b),(a + 2⁰ · b + 2¹ · b),...,(a + 2⁰ · b + 2¹ · b +...+2⁽ⁿ⁻¹⁾ · b) | |
You are given q queries in the form of a, b, and n. For each query, print the series corresponding to the given a, b, and n values as a single line of n space-separated integers. | |
Input Format | |
The first line contains an integer, q, denoting the number of queries. | |
Each line i of the q subsequent lines contains three space-separated integers describing the respective a, b, and n values for that query. | |
Constraints | |
• 0 ≤ q ≤ 500 | |
• 0 ≤ a,b ≤ 50 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FeetAndInchesToCentimeters { | |
//This is a sample of Java Method overloading. | |
//My solution to a challenge from Udemy Java Programming Masterclass covering Java 11 & Java 17 | |
//by Tim Buchalka Lecture 58. | |
public static void main(String[] args) { | |
System.out.println(FeetAndInchesToCentimeters.calcFeetAndInchesToCentimeters(5,10)); | |
System.out.println(FeetAndInchesToCentimeters.calcFeetAndInchesToCentimeters(4,10)); | |
System.out.println(FeetAndInchesToCentimeters.calcFeetAndInchesToCentimeters(70)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import edu.duke.DirectoryResource; | |
import edu.duke.FileResource; | |
import edu.duke.Point; | |
import edu.duke.Shape; | |
import java.io.File; | |
/* example input file: | |
example.txt | |
2, 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Udemy | |
// Java Programming Masterclass covering Java 11 & Java 17 | |
// Playing Cat | |
// | |
// The cats spend most of the day playing. In particular, they play if the temperature is between 25 and 35 (inclusive). | |
// Unless it is summer, then the upper limit is 45 (inclusive) instead of 35. | |
// | |
// Write a method isCatPlaying that has 2 parameters. | |
// Method needs to return true if the cat is playing, otherwise return false | |
// 1st parameter should be of type boolean and be named summer it represents if it is summer. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Udemy | |
//Java Programming Masterclass covering Java 11 & Java 17 | |
//SecondsAndMinutesChallenge | |
//Create a method called getDurationString with two parameters, first parameter minutes and 2nd parameter seconds. | |
//You should validate that the first parameter minutes is >= 0. | |
//You should validate that the 2nd parameter seconds is >= 0 and <= 59. | |
//The method should return "Invalid value" in the method if either of the above are not true. | |
//If the parameters are valid then calculate how many hours minutes and seconds equal the minutes and seconds passed | |
//to this method and return that value as string in format "XXh YYm ZZs" where XX represents a number of hours, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Udemy | |
//Java Programming Masterclass covering Java 11 & Java 17 | |
//Switch Statement Challenge | |
// | |
//Create a new switch statement using char | |
//Create a new char variable | |
//Create a switch statement testing for | |
//A, B, C, D, E | |
//Display a message if any of these are found and break | |
//Add a default which displays a message saying not found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Udemy | |
//Java Programming Masterclass covering Java 11 & Java 17 | |
//Day of the Week Challenge | |
// | |
//Write a method with the name printDayOfTheWeek that has one parameter of type int and name it day. | |
// | |
//The method should not return any value (hint: void) | |
// | |
//Using a switch statement print "Sunday", "Monday", ... ,"Saturday" if the int parameter "day" is 0, 1, ... , 6 respectively, | |
//otherwise it should print "Invalid day". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Udemy | |
// Java Programming Masterclass covering Java 11 & Java 17 | |
// Number In Word | |
// | |
// Write a method called printNumberInWord. | |
// The method has one parameter number which is the whole number. | |
// The method needs to print "ZERO", "ONE", "TWO", ... "NINE", "OTHER" | |
// if the int parameter number is 0, 1, 2, .... 9 or other for any other number including negative numbers. | |
// You can use if-else statement or switch statement whatever is easier for you. | |
// |
OlderNewer