Skip to content

Instantly share code, notes, and snippets.

View letrongtanbs's full-sized avatar
😅
I may be slow to respond.

Lê Trọng Tân letrongtanbs

😅
I may be slow to respond.
View GitHub Profile
@letrongtanbs
letrongtanbs / hexNumber
Created February 7, 2017 18:29
Write a program that prompts the user to enter an integer between 0 and 15 and displays its corresponding hex number
package intro;
import userlib.TextIO;
public class intro {
public static void main(String[] args){
int x,y;
System.out.println("Enter a number to convert: ");
x = TextIO.getInt();
while(x<0||x>=16){
TextIO.putln("Wrong input, it must be lower than 15 and greater than 0");
@letrongtanbs
letrongtanbs / validPassword
Created February 7, 2017 18:27
(Check password ) Some websites impose certain rules for passwords. Write a method that checks whether a string is a valid password. Suppose the password rules are as follows: ■ A password must have at least eight characters. ■ A password consists of only letters and digits. ■ A password must contain at least two digits.
package intro;
import userlib.TextIO;
import java.util.*;
import java.lang.String;
import java.lang.Character;
public class CheckPassWord {
public static void main(String[] args){
String pwd;
TextIO.putln("Enter your password: ");
import java.util.Scanner;
import java.util.Random;
/**
*Candygame
*
*/
public class CandyGame {
public static void main(String[] args) {
System.out.println("Welcome to Candy Game");
@letrongtanbs
letrongtanbs / countyear
Created October 7, 2016 11:15
/** * (Find the number of years) Write a program that prompts the user to enter the * minutes (e.g., 1 billion), and displays the number of years and days for the minutes. * For simplicity, assume a year has 365 days. * * @author Tom * @Version (a version number or a date) */
/**
* (Find the number of years) Write a program that prompts the user to enter the
* minutes (e.g., 1 billion), and displays the number of years and days for the minutes.
* For simplicity, assume a year has 365 days.
*
* @author Tom
* @version (a version number or a date)
*/
import java.util.Scanner;
@letrongtanbs
letrongtanbs / monthlyPayment
Last active December 10, 2024 16:33
The output is the monthly payment and total payment, which can be obtained using the following formulas: monthlyPayment = loanAmount * monthlyInterestRate /(1 - 1 / Math.pow(1 + monthlyInterestRate, numberOfYears * 12)); totalPayment = monthlyPayment * numberOfYears * 12 So, the input needed for the program is the monthly interest rate, the leng…
/**
* The output is the monthly payment and total payment,
* which can be obtained using the following formulas:
* monthlyPayment = loanAmount * monthlyInterestRate /(1 - 1 / Math.pow(1 + monthlyInterestRate, numberOfYears * 12));
* totalPayment = monthlyPayment * numberOfYears * 12
* So, the input needed for the program is the monthly interest rate, the length of the loan in years, and the loan amount.
*
* @author Tom
* @version (a version number or a date)
@letrongtanbs
letrongtanbs / calculateTheAreaOfCircle
Created October 6, 2016 10:53
Excercise 2:: /**To declare one variable is constant, we have the structure: *final datatype Name = value; *example: *final double Pi = 3.14159 ; /*Pi will remain unchanged during class ... :) Write a main method to require the user to enter the radius , then print out the area of a circle based on the radius.. P / s: use the constant pi constan…
/**
* Write a description of class CalArea here.
*
* @author (Tom)
* @version (a version number or a date)
*/
import java.util.Scanner;
public class CalArea{
// instance variables - replace the example below with your own