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

Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 

Recently uploaded (20)

Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
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
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
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
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
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
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 

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()); } }