write a program to display the mathematical tables of 5 to 10 for 10 iterations in the given format :
Sample Output : Table of 5
5*1=5
5*2 = 10
------------
------------
5*10=50..
write d program by using either inputstreamreader or scanner classes
siddhartharao77:
What is the need of using inputstreamreader or scannerclass in this program. Because we know the value of statically.
Answers
Answered by
5
HERE IS A PROGRAM
............
coins = [1,5,10,25]
d = {}
# stores tuples of the form
(
# of coins, [coin list])
# finds the minimum
# of coins needed to
# make change for some number of cents def m(cents):
if cents in d.keys(): return d[cents] elif cents > 0: choices
= [(m(cents - x)[0] + 1, m(cents - x)[1] + [x]) for x in coins if cents >= x]
# given a list of tuples, python's min function
# uses the first element of each tuple for comparison d[cents]
= min(choices) return d[cents] else: d[0] =
(0, []) return d[0] for x in range(1, 100): val = m(x) print x,
"cents requires", val[0], "coins:", val[1]
............
coins = [1,5,10,25]
d = {}
# stores tuples of the form
(
# of coins, [coin list])
# finds the minimum
# of coins needed to
# make change for some number of cents def m(cents):
if cents in d.keys(): return d[cents] elif cents > 0: choices
= [(m(cents - x)[0] + 1, m(cents - x)[1] + [x]) for x in coins if cents >= x]
# given a list of tuples, python's min function
# uses the first element of each tuple for comparison d[cents]
= min(choices) return d[cents] else: d[0] =
(0, []) return d[0] for x in range(1, 100): val = m(x) print x,
"cents requires", val[0], "coins:", val[1]
Answered by
18
Heya There
Here is Your To The Question
import java.util.Scanner;
class MultiplicationTable {
public static void main(String args[]) {
int n, c; System.out.println("Enter an integer to print it's multiplication table");
Scanner in = new Scanner(System.in);
n = in.nextInt();
System.out.println("Multiplication table of "+n+" is :-");
for ( c = 1 ; c <= 10 ; c++ ) System.out.println(n+"*"+c+" = "+(n*c)); } }
Here is Your To The Question
import java.util.Scanner;
class MultiplicationTable {
public static void main(String args[]) {
int n, c; System.out.println("Enter an integer to print it's multiplication table");
Scanner in = new Scanner(System.in);
n = in.nextInt();
System.out.println("Multiplication table of "+n+" is :-");
for ( c = 1 ; c <= 10 ; c++ ) System.out.println(n+"*"+c+" = "+(n*c)); } }
Similar questions