SlideShare a Scribd company logo
1 of 4
Nama : Muhammad Tohir
Nim : 201181102
Seksi :01
Tugas 03
Account
import java.util.Scanner;
public class Account
{
public double Balance;
public Account(double initialBalance)
{
if (initialBalance > 0.0)
Balance = initialBalance;
Scanner input = new Scanner(System.in);
}
public void credit (double Amount)
{
Balance = Balance + Amount;
}
public double getBalance()
{
return Balance;
}
}
Accounttest
import java.util.Scanner;
public class accounttest
{
public static void main (String[]args)
{
Account account1 = new Account(50.00);
Account account2 = new Account(-7.53);
System.out.printf("Account1 balance :$%.2fnn",account1.getBalance());
System.out.printf("Account2 balance :$%.2fnn",account2.getBalance());
Scanner input = new Scanner(System.in);
double depositAmount;
System.out.print("Enter deposit amount for account1:" );
depositAmount = input.nextDouble();
System.out.printf("nadding %.2f to account1 blance nn",depositAmount);
account1.credit(depositAmount);
System.out.printf("account1 blance : $%.2fn",account1.getBalance());
System.out.printf("account2 blance : $%.2fn",account2.getBalance());
System.out.printf("Enter deposit account for account2: ");
depositAmount =input.nextDouble();
System.out.printf("nadding %.2f to account2 balancenn",
depositAmount);
account2.credit(depositAmount);
System.out.printf("account1 balance: $%.2fn",account1.getBalance());
System.out.printf("account2 balance : $%.2fn",aaccount2.getBalance());
}
}
Tmpj3 01 201181102muhammad_tohir

More Related Content

What's hot

Latihan visual basic 2010/Looping/Perulangan
Latihan visual basic 2010/Looping/PerulanganLatihan visual basic 2010/Looping/Perulangan
Latihan visual basic 2010/Looping/Perulangan
Nurul Arhaiyyu
 
Top 3 SWT Exceptions
Top 3 SWT ExceptionsTop 3 SWT Exceptions
Top 3 SWT Exceptions
Lakshmi Priya
 

What's hot (10)

cats.effect.IO - Scala Vienna Meetup February 2019
cats.effect.IO - Scala Vienna Meetup February 2019cats.effect.IO - Scala Vienna Meetup February 2019
cats.effect.IO - Scala Vienna Meetup February 2019
 
WAP to find out whether the number is prime or not in java
WAP to find out whether the number is prime or not in javaWAP to find out whether the number is prime or not in java
WAP to find out whether the number is prime or not in java
 
Vp4
Vp4Vp4
Vp4
 
Latihan visual basic 2010/Looping/Perulangan
Latihan visual basic 2010/Looping/PerulanganLatihan visual basic 2010/Looping/Perulangan
Latihan visual basic 2010/Looping/Perulangan
 
Top 3 SWT Exceptions
Top 3 SWT ExceptionsTop 3 SWT Exceptions
Top 3 SWT Exceptions
 
Dr Jammi Ashok - Introduction to Java Material (OOPs)
 Dr Jammi Ashok - Introduction to Java Material (OOPs) Dr Jammi Ashok - Introduction to Java Material (OOPs)
Dr Jammi Ashok - Introduction to Java Material (OOPs)
 
5 Rmi Print
5  Rmi Print5  Rmi Print
5 Rmi Print
 
B2. activity and intent
B2. activity and intentB2. activity and intent
B2. activity and intent
 
C#
C#C#
C#
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMPROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
 

Viewers also liked

Tugas latihan java tohir 1
Tugas latihan java tohir 1Tugas latihan java tohir 1
Tugas latihan java tohir 1
pencari buku
 
Persiapan UN by MGMP Fisika BPK PENABUR
Persiapan UN by MGMP Fisika BPK PENABURPersiapan UN by MGMP Fisika BPK PENABUR
Persiapan UN by MGMP Fisika BPK PENABUR
guest4f71ffe
 
Soal dan pembahasan tukpd ii tahun 2013
Soal dan pembahasan tukpd ii tahun 2013Soal dan pembahasan tukpd ii tahun 2013
Soal dan pembahasan tukpd ii tahun 2013
Ema Rachmawati
 
Kompetisi ipa kelas ix smp 2013 tingkat kecamatan
Kompetisi ipa kelas ix  smp 2013 tingkat kecamatan Kompetisi ipa kelas ix  smp 2013 tingkat kecamatan
Kompetisi ipa kelas ix smp 2013 tingkat kecamatan
Ema Rachmawati
 
Kompetisi ipa kelas viii smp 2013 tingkat kecamatan
Kompetisi ipa kelas viii  smp 2013 tingkat kecamatan Kompetisi ipa kelas viii  smp 2013 tingkat kecamatan
Kompetisi ipa kelas viii smp 2013 tingkat kecamatan
Ema Rachmawati
 
Soal kompetisi ipa tingkat kecamatan 2009 2010
Soal kompetisi ipa tingkat kecamatan 2009   2010Soal kompetisi ipa tingkat kecamatan 2009   2010
Soal kompetisi ipa tingkat kecamatan 2009 2010
Ema Rachmawati
 
Soal tryout KLS IX (IPA FISIKA)
Soal tryout KLS IX (IPA FISIKA)Soal tryout KLS IX (IPA FISIKA)
Soal tryout KLS IX (IPA FISIKA)
Fitri Immawati
 

Viewers also liked (11)

Tugas latihan java tohir 1
Tugas latihan java tohir 1Tugas latihan java tohir 1
Tugas latihan java tohir 1
 
Persiapan UN by MGMP Fisika BPK PENABUR
Persiapan UN by MGMP Fisika BPK PENABURPersiapan UN by MGMP Fisika BPK PENABUR
Persiapan UN by MGMP Fisika BPK PENABUR
 
Soal dan pembahasan tukpd ii tahun 2013
Soal dan pembahasan tukpd ii tahun 2013Soal dan pembahasan tukpd ii tahun 2013
Soal dan pembahasan tukpd ii tahun 2013
 
Virus dan Antivirus
Virus dan AntivirusVirus dan Antivirus
Virus dan Antivirus
 
Soal kompetisi ipa kls ix
Soal kompetisi ipa kls ixSoal kompetisi ipa kls ix
Soal kompetisi ipa kls ix
 
Kompetisi ipa kelas ix smp 2013 tingkat kecamatan
Kompetisi ipa kelas ix  smp 2013 tingkat kecamatan Kompetisi ipa kelas ix  smp 2013 tingkat kecamatan
Kompetisi ipa kelas ix smp 2013 tingkat kecamatan
 
Kompetisi ipa kelas viii smp 2013 tingkat kecamatan
Kompetisi ipa kelas viii  smp 2013 tingkat kecamatan Kompetisi ipa kelas viii  smp 2013 tingkat kecamatan
Kompetisi ipa kelas viii smp 2013 tingkat kecamatan
 
Rumus gerak lurus
Rumus gerak lurusRumus gerak lurus
Rumus gerak lurus
 
Soal kompetisi ipa tingkat kecamatan 2009 2010
Soal kompetisi ipa tingkat kecamatan 2009   2010Soal kompetisi ipa tingkat kecamatan 2009   2010
Soal kompetisi ipa tingkat kecamatan 2009 2010
 
Bab 6 Bioteknologi kelas 9G SMPN 264 Jakarta
Bab 6 Bioteknologi kelas 9G SMPN 264 JakartaBab 6 Bioteknologi kelas 9G SMPN 264 Jakarta
Bab 6 Bioteknologi kelas 9G SMPN 264 Jakarta
 
Soal tryout KLS IX (IPA FISIKA)
Soal tryout KLS IX (IPA FISIKA)Soal tryout KLS IX (IPA FISIKA)
Soal tryout KLS IX (IPA FISIKA)
 

Similar to Tmpj3 01 201181102muhammad_tohir

Java programI made this Account.java below. Using the attached cod.pdf
Java programI made this Account.java below. Using the attached cod.pdfJava programI made this Account.java below. Using the attached cod.pdf
Java programI made this Account.java below. Using the attached cod.pdf
fathimafancy
 
Bank Program in JavaBelow is my code(havent finished, but it be .pdf
Bank Program in JavaBelow is my code(havent finished, but it be .pdfBank Program in JavaBelow is my code(havent finished, but it be .pdf
Bank Program in JavaBelow is my code(havent finished, but it be .pdf
izabellejaeden956
 
I need help creating a basic and simple Java program. Here is the ex.pdf
I need help creating a basic and simple Java program. Here is the ex.pdfI need help creating a basic and simple Java program. Here is the ex.pdf
I need help creating a basic and simple Java program. Here is the ex.pdf
rajeshjangid1865
 
You are not setting any values for those variables(name, ID, interes.pdf
You are not setting any values for those variables(name, ID, interes.pdfYou are not setting any values for those variables(name, ID, interes.pdf
You are not setting any values for those variables(name, ID, interes.pdf
deepakangel
 
Automatically Repairing Test Cases for Evolving Method Declarations
Automatically Repairing Test Cases for Evolving Method DeclarationsAutomatically Repairing Test Cases for Evolving Method Declarations
Automatically Repairing Test Cases for Evolving Method Declarations
ICSM 2010
 
public class InsufficientFundsException extends Exception{Insuffic.pdf
public class InsufficientFundsException extends Exception{Insuffic.pdfpublic class InsufficientFundsException extends Exception{Insuffic.pdf
public class InsufficientFundsException extends Exception{Insuffic.pdf
ankitcom
 
The java class Account that simultes the Account class.pdf
   The java class Account that simultes  the Account class.pdf   The java class Account that simultes  the Account class.pdf
The java class Account that simultes the Account class.pdf
akshay1213
 
Hi,I have updated the code as per your requirement. Highlighted th.pdf
Hi,I have updated the code as per your requirement. Highlighted th.pdfHi,I have updated the code as per your requirement. Highlighted th.pdf
Hi,I have updated the code as per your requirement. Highlighted th.pdf
annaindustries
 
Write a Java ProgramSolutionAnswer- Code- import java-io--- import jav.docx
Write a Java ProgramSolutionAnswer- Code- import java-io--- import jav.docxWrite a Java ProgramSolutionAnswer- Code- import java-io--- import jav.docx
Write a Java ProgramSolutionAnswer- Code- import java-io--- import jav.docx
lez31palka
 
import java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdfimport java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdf
optokunal1
 
import java.util.Scanner; public class Rainfall {Scanner s=new.pdf
import java.util.Scanner; public class Rainfall {Scanner s=new.pdfimport java.util.Scanner; public class Rainfall {Scanner s=new.pdf
import java.util.Scanner; public class Rainfall {Scanner s=new.pdf
ssuserd6ce341
 

Similar to Tmpj3 01 201181102muhammad_tohir (20)

Bank account in java
Bank account in javaBank account in java
Bank account in java
 
Java programI made this Account.java below. Using the attached cod.pdf
Java programI made this Account.java below. Using the attached cod.pdfJava programI made this Account.java below. Using the attached cod.pdf
Java programI made this Account.java below. Using the attached cod.pdf
 
Bank Program in JavaBelow is my code(havent finished, but it be .pdf
Bank Program in JavaBelow is my code(havent finished, but it be .pdfBank Program in JavaBelow is my code(havent finished, but it be .pdf
Bank Program in JavaBelow is my code(havent finished, but it be .pdf
 
IP project for class 12 cbse
IP project for class 12 cbseIP project for class 12 cbse
IP project for class 12 cbse
 
I need help creating a basic and simple Java program. Here is the ex.pdf
I need help creating a basic and simple Java program. Here is the ex.pdfI need help creating a basic and simple Java program. Here is the ex.pdf
I need help creating a basic and simple Java program. Here is the ex.pdf
 
You are not setting any values for those variables(name, ID, interes.pdf
You are not setting any values for those variables(name, ID, interes.pdfYou are not setting any values for those variables(name, ID, interes.pdf
You are not setting any values for those variables(name, ID, interes.pdf
 
Automatically Repairing Test Cases for Evolving Method Declarations
Automatically Repairing Test Cases for Evolving Method DeclarationsAutomatically Repairing Test Cases for Evolving Method Declarations
Automatically Repairing Test Cases for Evolving Method Declarations
 
public class InsufficientFundsException extends Exception{Insuffic.pdf
public class InsufficientFundsException extends Exception{Insuffic.pdfpublic class InsufficientFundsException extends Exception{Insuffic.pdf
public class InsufficientFundsException extends Exception{Insuffic.pdf
 
The java class Account that simultes the Account class.pdf
   The java class Account that simultes  the Account class.pdf   The java class Account that simultes  the Account class.pdf
The java class Account that simultes the Account class.pdf
 
Inheritance
InheritanceInheritance
Inheritance
 
Programs of java
Programs of javaPrograms of java
Programs of java
 
Modify the Total program so that it writes the values in two columns.pdf
Modify the Total program so that it writes the values in two columns.pdfModify the Total program so that it writes the values in two columns.pdf
Modify the Total program so that it writes the values in two columns.pdf
 
programming for Calculator in java
programming for Calculator in javaprogramming for Calculator in java
programming for Calculator in java
 
OOP program questions with answers
OOP program questions with answersOOP program questions with answers
OOP program questions with answers
 
Hi,I have updated the code as per your requirement. Highlighted th.pdf
Hi,I have updated the code as per your requirement. Highlighted th.pdfHi,I have updated the code as per your requirement. Highlighted th.pdf
Hi,I have updated the code as per your requirement. Highlighted th.pdf
 
Write a Java ProgramSolutionAnswer- Code- import java-io--- import jav.docx
Write a Java ProgramSolutionAnswer- Code- import java-io--- import jav.docxWrite a Java ProgramSolutionAnswer- Code- import java-io--- import jav.docx
Write a Java ProgramSolutionAnswer- Code- import java-io--- import jav.docx
 
Creating a Facebook Clone - Part XLVI - Transcript.pdf
Creating a Facebook Clone - Part XLVI - Transcript.pdfCreating a Facebook Clone - Part XLVI - Transcript.pdf
Creating a Facebook Clone - Part XLVI - Transcript.pdf
 
import java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdfimport java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdf
 
Write a Java application that asks for an integer and returns its fac.pdf
Write a Java application that asks for an integer and returns its fac.pdfWrite a Java application that asks for an integer and returns its fac.pdf
Write a Java application that asks for an integer and returns its fac.pdf
 
import java.util.Scanner; public class Rainfall {Scanner s=new.pdf
import java.util.Scanner; public class Rainfall {Scanner s=new.pdfimport java.util.Scanner; public class Rainfall {Scanner s=new.pdf
import java.util.Scanner; public class Rainfall {Scanner s=new.pdf
 

Recently uploaded

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 

Recently uploaded (20)

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 

Tmpj3 01 201181102muhammad_tohir

  • 1. Nama : Muhammad Tohir Nim : 201181102 Seksi :01 Tugas 03 Account import java.util.Scanner; public class Account { public double Balance; public Account(double initialBalance) { if (initialBalance > 0.0) Balance = initialBalance; Scanner input = new Scanner(System.in); } public void credit (double Amount) { Balance = Balance + Amount; } public double getBalance() { return Balance; } }
  • 2. Accounttest import java.util.Scanner; public class accounttest { public static void main (String[]args) { Account account1 = new Account(50.00); Account account2 = new Account(-7.53); System.out.printf("Account1 balance :$%.2fnn",account1.getBalance()); System.out.printf("Account2 balance :$%.2fnn",account2.getBalance()); Scanner input = new Scanner(System.in); double depositAmount; System.out.print("Enter deposit amount for account1:" ); depositAmount = input.nextDouble(); System.out.printf("nadding %.2f to account1 blance nn",depositAmount); account1.credit(depositAmount); System.out.printf("account1 blance : $%.2fn",account1.getBalance()); System.out.printf("account2 blance : $%.2fn",account2.getBalance()); System.out.printf("Enter deposit account for account2: "); depositAmount =input.nextDouble();
  • 3. System.out.printf("nadding %.2f to account2 balancenn", depositAmount); account2.credit(depositAmount); System.out.printf("account1 balance: $%.2fn",account1.getBalance()); System.out.printf("account2 balance : $%.2fn",aaccount2.getBalance()); } }