Skip to content

Latest commit

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Notes-on-Initial-Programming

Description

Notes-on-Initial-Programming

Table of Contents of Brightspace Module

Lecture 1

Lecture 2 (not found)

Lecture 3

Lecture 4


Lab Week 5

no later content than this on 2023-10-16-at-1529h

Content

Week-6

Lecture-Week-6

Digital Ocean

Let’s look at the available format specifiers available for printf:

%c character

%d decimal (integer) number (base 10)

%e exponential floating-point number

%f floating-point number

%i integer (base 10)

%o octal number (base 8)

%s String

%u unsigned decimal (integer) number

%x number in hexadecimal (base 16)

%t formats date/time

%% print a percent sign

% print a percent sign

ChatGPT3_5

In the System.out.printf method in Java (and similar formatting in other programming languages), the % symbol is used to indicate a placeholder for a value to be inserted into the string being formatted. The characters following % specify the formatting for the value

that will be inserted.

In the example "%9.7f":

% indicates the start of the formatting specifier.

9 specifies the minimum width of the field where the value will be inserted. In this case, it's saying that the minimum width is 9 characters. If the inserted value is less than 9 characters wide, it will be padded with spaces to the left.

.7 specifies the precision for floating-point numbers. It indicates that 7 decimal places should be shown.

f specifies that the value being inserted should be formatted as a floating-point number.

So, in summary, %9.7f is a formatting specifier for a floating-point number with a minimum width of 9 characters and 7 decimal places of precision.

publicclassPrintPi {
publicstaticvoidmain(String[] args) {
doublepiValue = Math.PI;
System.out.printf("Value of PI to 7 dec is %9.7f\n", piValue);
}
}
System.out.printf("Value of PI to 4 dec is %9.4f\n", Math.PI);
System.out.printf("Value of PI to 2 dec is %-9.2f\n", Math.PI);

W6 Lec PART 2
ASCII Table

ChatGPT3_5

In Java, you can utilize the Character class to work with characters and perform the mentioned operations. Here's a brief guide on using Character for the specified tasks:

Checking if a Character is a Digit:

java Copy code char ch = '7'; boolean isDigit = Character.isDigit(ch); Checking if a Character is a Letter:

charch = 'A';
booleanisLetter = Character.isLetter(ch);
CheckingifaCharacterisUppercase:
charch = 'C';
booleanisUppercase = Character.isUpperCase(ch);
CheckingifaCharacterisLowercase:
charch = 'd';
booleanisLowercase = Character.isLowerCase(ch);
ConvertingaCharactertoLowercaseorUppercase:
charch = 'A';
charlowercaseCh = Character.toLowerCase(ch);
charuppercaseCh = Character.toUpperCase(ch);
GeneratingaRandomUppercaseLetter:
charrandomUppercase = (char) ('A' + (int) (Math.random() * 26));
ThesefunctionsallowyoutomanipulateanddeterminepropertiesofcharactersinJava. Letmeknowifyouneedfurtherclarificationoradditionalcodeexamples!

Storing Data (Fixed)

Storing Data (Dynamic)

In fixed size rep var point at data

in dyn var point at ref pointing at date

... if change to the date the reference might change....


Refrerences

Printf

geeksforgeeks Printf

digital ocean Printf

ASCII Table

Releases

Packages

Contributors