SlideShare uma empresa Scribd logo
1 de 15
SET INDUKSI
APAKAH FUNGSI PENYATAAN TERSEBUT DALAM
ATURCARA?
1. System.out.println
2.//
3.int umur;
4.float gaji;
5.public class ScanLine
6.{
7.}
Analisis aturcara dibawah
public class InputExp {
public static void main(String[] args) {
int nom1;
int nom2;
hasilDarab;
nom1=3, nom2=9;
hasilDarab=nom1*nom2;
System.out.println (“Hasil Darab nom1 dan nom2 = ” +hasilDarab);
Objektif Pembelajaran
Pelajar dapat:
1. Menulis aturcara bagi menerima input daripada pengguna dari
console
2. Mengetahui fungsi Method nextInt, nextDouble, nextLine, nextFloat
dalam kelas Scanner;
3. Tahu membezakan penggunaan jenis data bagi setiap pembolehubah.
Membaca Input dari
Pengguna
KELAS SCANNER
Kelas Scanner
 Kelas Scanner merupakan kelas dalam java.util.
 Ia membenarkan pengguna memasukkan pelbagai jenis nilai
seperti integer, nombor perpuluhan ataupun teks
 Nilai dimasukkan oleh pengguna dalam console
 Arahan berikut diperlukan :
1. import java.util.Scanner;
2. Scanner input = new Scanner(System.in);
JOM BINA ATURCARA
Analogi (Aliran air Kepada Pengguna)
Analogi (masuk input dari Pengguna)
System.in
Scanner input=
new Scanner
input.nextLine
String nama=
input.nextLine();
Jenis Data method Function
Int nextInt () Returns the next token as an int. If the next token is not an integer,
InputMismatchException is thrown.
Long nextLong() Returns the next token as a long. If the next token is not an integer,
InputMismatchException is thrown.
Float nextFloat () Returns the next token as a float. If the next token is not a float or is out
of range, InputMismatchException is thrown.
Double nextDouble () Returns the next token as a long. If the next token is not a float or is out
of range, InputMismatchException is thrown.
String Next () Finds and returns the next complete token from this scanner and returns
it as a string; a token is usually ended by whitespace such as a blank or
line break. If not token exists,NoSuchElementException is thrown.
String NextLine () Returns the rest of the current line, excluding any line separator at the
end.
void Close () Closes the scanner.
Contoh Penggunaan Method Scanner
int number = in.nextInt();
float real = in.nextFloat();
long number2 = in.nextLong();
double real2 = in.nextDouble();
String string = in.next();
Contoh aturcara 1
import java.util.Scanner;
public class InputExp {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// Reads a single line from the console
// and stores into name variable
System.out.println (“Please Key In Your Name”);
String name = in.nextLine();
// Reads a integer from the console
// and stores into age variable
System.out.println (“Please Key In Your Age”);
int age=in.nextInt();
// Prints name and age to the console
System.out.println("Name :"+name);
System.out.println("Age :"+age);
}
}
Aturcara 2:
Aturcara 3
import java.util.Scanner;
public class ScanLine {
public static void main(String[] args) {
// create a scanner object
Scanner scanner = new Scanner(System.in);
// input an int from the user
System.out.println("Enter an int");
int i = scanner.nextInt();
// now, try to input a whole line from the user
System.out.println("Enter a sentence -- spaces are allowed");
String s1 = scanner.nextLine();
// input a string from the user
System.out.println("Enter a String -- with no spaces");
String s2 = scanner.nextLine();
// output data to the user
System.out.println("i = " + i);
System.out.println("s1 = " + s1);
System.out.println("s2 = " + s2);
}
}
Aturcara 4
import java.util.Scanner;
import java.io.*; // Access System.out
public class NumericInput
{
public static void main(String[] args)
{
// Declarations
Scanner in = new Scanner(System.in);
int integer;
long longInteger;
float realNumber;
double doubleReal;
String string1;
String string2;
// Prompts
System.out.println("Enter an integer, a long integer, "
+ "a floating-point ");
System.out.println("number, another floating-point number, "
+ "and a string.");
System.out.println("Separate each with a blank or enter.");
// Read in values
integer = in.nextInt();
longInteger = in.nextLong();
realNumber = in.nextFloat();
doubleReal = in.nextDouble();
string1 = in.nextLine();
System.out.println("Now enter another value.");
string2 = in.next();
System.out.println("Here is what you entered: ");
System.out.println(integer + " " + longInteger + " " +
realNumber + " " + doubleReal + " " + string1 +" and " + string2);
}
}
Output:
Enter an integer, a long integer, a floating-point
number, another floating-point number, and a string.
Separate each with a blank or enter.
23
24
25.0 233333333333333.444 Hello
Now enter another value.
23.4
Here is what you entered:
23 24 25.0 2.3333333333333344E14 Hello and 23.4
LATIHAN
1. Anda dikehendaki membina aturcara bagi mengira hasil tambah 3 nombor yang
dimasukkan oleh pengguna.
2. Anda dikehendaki membina aturcara bagi mengira hasil darab 3 nombor yang
dimasukkan oleh pengguna.
3. Anda dikehendaki membina aturcara bagi mengira purata 5 markah pelajar. Markah
tersebut merupakan markah kuiz, tugasan, amali, pembentangan dan ujian.
4. Anda dikehendaki membina aturcara dengan meminta input nama, no telefon, umur,
bilangan adik beradik dan pendapatan penjaga. Output kan semula maklumat yang
telah dimasukkan.
5. Anda dikehendaki membina aturcara bagi mengira keluasan padang bola sepak yang
berbentuk segiempat tepat.
6. Anda dikehendaki membina aturcara mengira isipadu satu tin minuman. Gunakan
pernyataan berikut bagi Pemalar (Constant): final double pie =3.142
p/s: gunakan algoritma pseudokod, carta alir untuk anda membantu anda membuat aturcara

Mais conteúdo relacionado

Mais procurados

Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple ProgramsUpender Upr
 
Антихрупкий TypeScript | Odessa Frontend Meetup #17
Антихрупкий TypeScript | Odessa Frontend Meetup #17Антихрупкий TypeScript | Odessa Frontend Meetup #17
Антихрупкий TypeScript | Odessa Frontend Meetup #17OdessaFrontend
 
New Functional Features of Java 8
New Functional Features of Java 8New Functional Features of Java 8
New Functional Features of Java 8franciscoortin
 
Control statements
Control statementsControl statements
Control statementsraksharao
 
Java simple programs
Java simple programsJava simple programs
Java simple programsVEERA RAGAVAN
 
Import java
Import javaImport java
Import javaheni2121
 
JPC#8 Introduction to Java Programming
JPC#8 Introduction to Java ProgrammingJPC#8 Introduction to Java Programming
JPC#8 Introduction to Java ProgrammingPathomchon Sriwilairit
 
C++ Course - Lesson 3
C++ Course - Lesson 3C++ Course - Lesson 3
C++ Course - Lesson 3Mohamed Ahmed
 
12. Java Exceptions and error handling
12. Java Exceptions and error handling12. Java Exceptions and error handling
12. Java Exceptions and error handlingIntro C# Book
 

Mais procurados (17)

Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple Programs
 
ScalaFlavor4J
ScalaFlavor4JScalaFlavor4J
ScalaFlavor4J
 
Антихрупкий TypeScript | Odessa Frontend Meetup #17
Антихрупкий TypeScript | Odessa Frontend Meetup #17Антихрупкий TypeScript | Odessa Frontend Meetup #17
Антихрупкий TypeScript | Odessa Frontend Meetup #17
 
Java input
Java inputJava input
Java input
 
New Functional Features of Java 8
New Functional Features of Java 8New Functional Features of Java 8
New Functional Features of Java 8
 
Control statements
Control statementsControl statements
Control statements
 
Java simple programs
Java simple programsJava simple programs
Java simple programs
 
Import java
Import javaImport java
Import java
 
JPC#8 Introduction to Java Programming
JPC#8 Introduction to Java ProgrammingJPC#8 Introduction to Java Programming
JPC#8 Introduction to Java Programming
 
Java programs
Java programsJava programs
Java programs
 
Swift Programming - Part 2
Swift Programming - Part 2Swift Programming - Part 2
Swift Programming - Part 2
 
JAVA OOP
JAVA OOPJAVA OOP
JAVA OOP
 
Java programs
Java programsJava programs
Java programs
 
C++ Course - Lesson 3
C++ Course - Lesson 3C++ Course - Lesson 3
C++ Course - Lesson 3
 
12. Java Exceptions and error handling
12. Java Exceptions and error handling12. Java Exceptions and error handling
12. Java Exceptions and error handling
 
For Beginners - C#
For Beginners - C#For Beginners - C#
For Beginners - C#
 
Simple Java Programs
Simple Java ProgramsSimple Java Programs
Simple Java Programs
 

Semelhante a KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer

Lab01.pptx
Lab01.pptxLab01.pptx
Lab01.pptxKimVeeL
 
JAVA Question : Programming Assignment
JAVA Question : Programming AssignmentJAVA Question : Programming Assignment
JAVA Question : Programming AssignmentCoding Assignment Help
 
Frequency .java Word frequency counter package frequ.pdf
Frequency .java  Word frequency counter  package frequ.pdfFrequency .java  Word frequency counter  package frequ.pdf
Frequency .java Word frequency counter package frequ.pdfarshiartpalace
 
Star pattern programs in java Print Star pattern in java and print triangle ...
Star pattern programs in java Print Star pattern in java and  print triangle ...Star pattern programs in java Print Star pattern in java and  print triangle ...
Star pattern programs in java Print Star pattern in java and print triangle ...Hiraniahmad
 
Lab101.pptx
Lab101.pptxLab101.pptx
Lab101.pptxKimVeeL
 
Prompt a user to enter a series of integers separated by spaces and .pdf
Prompt a user to enter a series of integers separated by spaces and .pdfPrompt a user to enter a series of integers separated by spaces and .pdf
Prompt a user to enter a series of integers separated by spaces and .pdfFootageetoffe16
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfmayorothenguyenhob69
 
import java.uti-WPS Office.docx
import java.uti-WPS Office.docximport java.uti-WPS Office.docx
import java.uti-WPS Office.docxKatecate1
 
Digits.javapackage week04;import java.util.Scanner; public cla.pdf
Digits.javapackage week04;import java.util.Scanner; public cla.pdfDigits.javapackage week04;import java.util.Scanner; public cla.pdf
Digits.javapackage week04;import java.util.Scanner; public cla.pdfannapurnnatextailes
 

Semelhante a KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer (20)

Lab01.pptx
Lab01.pptxLab01.pptx
Lab01.pptx
 
JAVA Question : Programming Assignment
JAVA Question : Programming AssignmentJAVA Question : Programming Assignment
JAVA Question : Programming Assignment
 
Java file
Java fileJava file
Java file
 
Java file
Java fileJava file
Java file
 
Frequency .java Word frequency counter package frequ.pdf
Frequency .java  Word frequency counter  package frequ.pdfFrequency .java  Word frequency counter  package frequ.pdf
Frequency .java Word frequency counter package frequ.pdf
 
Star pattern programs in java Print Star pattern in java and print triangle ...
Star pattern programs in java Print Star pattern in java and  print triangle ...Star pattern programs in java Print Star pattern in java and  print triangle ...
Star pattern programs in java Print Star pattern in java and print triangle ...
 
07-Basic-Input-Output.ppt
07-Basic-Input-Output.ppt07-Basic-Input-Output.ppt
07-Basic-Input-Output.ppt
 
Java practical
Java practicalJava practical
Java practical
 
3.Lesson Plan - Input.pdf.pdf
3.Lesson Plan - Input.pdf.pdf3.Lesson Plan - Input.pdf.pdf
3.Lesson Plan - Input.pdf.pdf
 
Lab101.pptx
Lab101.pptxLab101.pptx
Lab101.pptx
 
Prompt a user to enter a series of integers separated by spaces and .pdf
Prompt a user to enter a series of integers separated by spaces and .pdfPrompt a user to enter a series of integers separated by spaces and .pdf
Prompt a user to enter a series of integers separated by spaces and .pdf
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdf
 
import java.uti-WPS Office.docx
import java.uti-WPS Office.docximport java.uti-WPS Office.docx
import java.uti-WPS Office.docx
 
Digits.javapackage week04;import java.util.Scanner; public cla.pdf
Digits.javapackage week04;import java.util.Scanner; public cla.pdfDigits.javapackage week04;import java.util.Scanner; public cla.pdf
Digits.javapackage week04;import java.util.Scanner; public cla.pdf
 
Introduction to Java Programming Part 2
Introduction to Java Programming Part 2Introduction to Java Programming Part 2
Introduction to Java Programming Part 2
 
Problemas secuenciales.
Problemas secuenciales.Problemas secuenciales.
Problemas secuenciales.
 
Problemas secuenciales.
Problemas secuenciales.Problemas secuenciales.
Problemas secuenciales.
 
Problemas secuenciales.
Problemas secuenciales.Problemas secuenciales.
Problemas secuenciales.
 
Problemas secuenciales.
Problemas secuenciales.Problemas secuenciales.
Problemas secuenciales.
 
Problemas secuenciales.
Problemas secuenciales.Problemas secuenciales.
Problemas secuenciales.
 

Mais de Aiman Hud

POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 

Mais de Aiman Hud (20)

POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 

Último

Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfYashikaSharma391629
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 

Último (20)

Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 

KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer

  • 1. SET INDUKSI APAKAH FUNGSI PENYATAAN TERSEBUT DALAM ATURCARA? 1. System.out.println 2.// 3.int umur; 4.float gaji; 5.public class ScanLine 6.{ 7.}
  • 2. Analisis aturcara dibawah public class InputExp { public static void main(String[] args) { int nom1; int nom2; hasilDarab; nom1=3, nom2=9; hasilDarab=nom1*nom2; System.out.println (“Hasil Darab nom1 dan nom2 = ” +hasilDarab);
  • 3. Objektif Pembelajaran Pelajar dapat: 1. Menulis aturcara bagi menerima input daripada pengguna dari console 2. Mengetahui fungsi Method nextInt, nextDouble, nextLine, nextFloat dalam kelas Scanner; 3. Tahu membezakan penggunaan jenis data bagi setiap pembolehubah.
  • 5. Kelas Scanner  Kelas Scanner merupakan kelas dalam java.util.  Ia membenarkan pengguna memasukkan pelbagai jenis nilai seperti integer, nombor perpuluhan ataupun teks  Nilai dimasukkan oleh pengguna dalam console  Arahan berikut diperlukan : 1. import java.util.Scanner; 2. Scanner input = new Scanner(System.in); JOM BINA ATURCARA
  • 6. Analogi (Aliran air Kepada Pengguna)
  • 7. Analogi (masuk input dari Pengguna) System.in Scanner input= new Scanner input.nextLine String nama= input.nextLine();
  • 8. Jenis Data method Function Int nextInt () Returns the next token as an int. If the next token is not an integer, InputMismatchException is thrown. Long nextLong() Returns the next token as a long. If the next token is not an integer, InputMismatchException is thrown. Float nextFloat () Returns the next token as a float. If the next token is not a float or is out of range, InputMismatchException is thrown. Double nextDouble () Returns the next token as a long. If the next token is not a float or is out of range, InputMismatchException is thrown. String Next () Finds and returns the next complete token from this scanner and returns it as a string; a token is usually ended by whitespace such as a blank or line break. If not token exists,NoSuchElementException is thrown. String NextLine () Returns the rest of the current line, excluding any line separator at the end. void Close () Closes the scanner.
  • 9. Contoh Penggunaan Method Scanner int number = in.nextInt(); float real = in.nextFloat(); long number2 = in.nextLong(); double real2 = in.nextDouble(); String string = in.next();
  • 10. Contoh aturcara 1 import java.util.Scanner; public class InputExp { public static void main(String[] args) { Scanner in = new Scanner(System.in); // Reads a single line from the console // and stores into name variable System.out.println (“Please Key In Your Name”); String name = in.nextLine(); // Reads a integer from the console // and stores into age variable System.out.println (“Please Key In Your Age”); int age=in.nextInt(); // Prints name and age to the console System.out.println("Name :"+name); System.out.println("Age :"+age); } }
  • 12. Aturcara 3 import java.util.Scanner; public class ScanLine { public static void main(String[] args) { // create a scanner object Scanner scanner = new Scanner(System.in); // input an int from the user System.out.println("Enter an int"); int i = scanner.nextInt(); // now, try to input a whole line from the user System.out.println("Enter a sentence -- spaces are allowed"); String s1 = scanner.nextLine(); // input a string from the user System.out.println("Enter a String -- with no spaces"); String s2 = scanner.nextLine(); // output data to the user System.out.println("i = " + i); System.out.println("s1 = " + s1); System.out.println("s2 = " + s2); } }
  • 13. Aturcara 4 import java.util.Scanner; import java.io.*; // Access System.out public class NumericInput { public static void main(String[] args) { // Declarations Scanner in = new Scanner(System.in); int integer; long longInteger; float realNumber; double doubleReal; String string1; String string2; // Prompts System.out.println("Enter an integer, a long integer, " + "a floating-point "); System.out.println("number, another floating-point number, " + "and a string."); System.out.println("Separate each with a blank or enter."); // Read in values integer = in.nextInt(); longInteger = in.nextLong(); realNumber = in.nextFloat(); doubleReal = in.nextDouble(); string1 = in.nextLine(); System.out.println("Now enter another value."); string2 = in.next(); System.out.println("Here is what you entered: "); System.out.println(integer + " " + longInteger + " " + realNumber + " " + doubleReal + " " + string1 +" and " + string2); } }
  • 14. Output: Enter an integer, a long integer, a floating-point number, another floating-point number, and a string. Separate each with a blank or enter. 23 24 25.0 233333333333333.444 Hello Now enter another value. 23.4 Here is what you entered: 23 24 25.0 2.3333333333333344E14 Hello and 23.4
  • 15. LATIHAN 1. Anda dikehendaki membina aturcara bagi mengira hasil tambah 3 nombor yang dimasukkan oleh pengguna. 2. Anda dikehendaki membina aturcara bagi mengira hasil darab 3 nombor yang dimasukkan oleh pengguna. 3. Anda dikehendaki membina aturcara bagi mengira purata 5 markah pelajar. Markah tersebut merupakan markah kuiz, tugasan, amali, pembentangan dan ujian. 4. Anda dikehendaki membina aturcara dengan meminta input nama, no telefon, umur, bilangan adik beradik dan pendapatan penjaga. Output kan semula maklumat yang telah dimasukkan. 5. Anda dikehendaki membina aturcara bagi mengira keluasan padang bola sepak yang berbentuk segiempat tepat. 6. Anda dikehendaki membina aturcara mengira isipadu satu tin minuman. Gunakan pernyataan berikut bagi Pemalar (Constant): final double pie =3.142 p/s: gunakan algoritma pseudokod, carta alir untuk anda membantu anda membuat aturcara