Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
k2024
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tie
ohj2
esimerkit
k2024
Commits
8a415f01
Commit
8a415f01
authored
1 year ago
by
Vesa Lappalainen
Browse files
Options
Downloads
Patches
Plain Diff
ht6 alku
parent
0fb269f8
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
luennot/live18/src/tiedosto/Kertotaulu7.java
+52
-0
52 additions, 0 deletions
luennot/live18/src/tiedosto/Kertotaulu7.java
luennot/live18/taulu.txt
+21
-0
21 additions, 0 deletions
luennot/live18/taulu.txt
with
73 additions
and
0 deletions
luennot/live18/src/tiedosto/Kertotaulu7.java
0 → 100644
+
52
−
0
View file @
8a415f01
package
tiedosto
;
import
java.io.*
;
/**
* Ohjelmalla tulostetaan kertotaulu tiedostoon. Jos tiedosto on
* olemassa, jatketaan vanhan tiedoston perään.
* @author Vesa Lappalainen
* @version 1.0, 21.02.2003
* @version 1.1, 4.03.2012
*/
public
class
Kertotaulu7
{
/**
* Kertotaulu tiedostoon.
* @param args tiedoston nimi
* @example
* <pre name="test">
* #THROWS IOException
* #import java.io.IOException;
* #import fi.jyu.mit.ohj2.VertaaTiedosto;
* String tiednimi = "kertotaulu7koe.txt";
* VertaaTiedosto.tuhoaTiedosto(tiednimi);
* main(new String[]{tiednimi});
* String tulos = " 0 * 5 = 0\n"+
* " 1 * 5 = 5\n"+
* " 2 * 5 = 10\n"+
* " 3 * 5 = 15\n"+
* " 4 * 5 = 20\n"+
* " 5 * 5 = 25\n"+
* " 6 * 5 = 30\n"+
* " 7 * 5 = 35\n"+
* " 8 * 5 = 40\n"+
* " 9 * 5 = 45\n";
* VertaaTiedosto.vertaaFileString(tiednimi,tulos) === null;
* main(new String[]{tiednimi});
* VertaaTiedosto.vertaaFileString(tiednimi,tulos+tulos) === null;
* VertaaTiedosto.tuhoaTiedosto(tiednimi);
* </pre>
*/
public
static
void
main
(
String
[]
args
)
{
String
tiedNimi
=
"taulu.txt"
;
if
(
args
.
length
>
0
)
tiedNimi
=
args
[
0
];
try
(
PrintStream
fo
=
new
PrintStream
(
new
FileOutputStream
(
tiedNimi
,
true
)))
{
int
kerroin
=
5
;
for
(
int
i
=
0
;
i
<=
10
;
i
++)
fo
.
printf
(
"%2d * %d = %3d\n"
,
i
,
kerroin
,
i
*
kerroin
);
}
catch
(
FileNotFoundException
ex
)
{
System
.
err
.
println
(
"Tiedosto ei aukea: "
+
ex
.
getMessage
());
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
luennot/live18/taulu.txt
0 → 100644
+
21
−
0
View file @
8a415f01
0 * 5 = 0
1 * 5 = 5
2 * 5 = 10
3 * 5 = 15
4 * 5 = 20
5 * 5 = 25
6 * 5 = 30
7 * 5 = 35
8 * 5 = 40
9 * 5 = 45
0 * 5 = 0
1 * 5 = 5
2 * 5 = 10
3 * 5 = 15
4 * 5 = 20
5 * 5 = 25
6 * 5 = 30
7 * 5 = 35
8 * 5 = 40
9 * 5 = 45
10 * 5 = 50
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment