For example, I have this code to multiply 2 numbers without using the * symbol, but how can I achieve the same with negative numbers?
public static void main(String[] args) {
// TODO code application logic here
Scanner in = new Scanner(System.in);
int result = 0;
System.out.println("Enter the first number: ");
int num1 = in.nextInt();
System.out.println("Enter the second number: ");
int num2 = in.nextInt();
if(num1==0 || num2==0) {
System.out.println("the profuct of these numbers is: 0");
}
for(int i =0; i <num1; i++)
{
result += num2;
}
System.out.println("the profuct od these numbers is: "+result);
}
}