import java.util.Scanner;
public class MultiplyWith7
{
private Integer num, res;
//private double res1;// for another solution to this problem
public void getNum(Integer n)
{
num = n;
}
public void CalculateResult()
{
//res1 = num/((double)1/7);// then print res1
res = num<<3;
res = res-num;
}
public void showResult()
{
System.out.println("The result of "+num+"*7 is : "+res);
}
public static void main(String []args)
{
MultiplyWith7 obj = new MultiplyWith7();
Scanner input = new Scanner(System.in);
System.out.println("Enter the number : ");
obj.getNum(input.nextInt());
obj.CalculateResult();
obj.showResult();
input.close();
}
}
Sometimes the only way to move forward is to revisit the things in your past that were holding you back. You have to deal with them head on, no matter how scary they may be. Because once we do, you'll see that you can go further than you ever imagined. सो जाएँगे कल लिपटकर तिरंगे के साथ अलमारी में... देशभक्ति है साहब.... तारीखों पर जागती है। The only way out is through.
Saturday, 19 March 2016
Java program to multiply any number with 7 without using * and + operator
Labels:
Java
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment