1) Convert the following Java code by using a function in C++, Python. public class lab9{ public static void main(String []args) { System.out.println(" System.out.println(" System.out.println(" System.out.println(" The output is public static int cale (int arg1, int arg2, char arg3) { int total=0; if (arg3 =='+') } total = arg1 + arg2; if (arg3==¹*¹) total = arg1 * arg2; if (arg3 == '-') total = arglarg2; if (arg3 == '/') 10+ 20 = " + calc(10,20,'+')); 10 * 20 = " + calc( 10, 20, '*')); 10 - 20 = " + calc( 10, 20, '-')); 10/20 = " + calc( 10, 20, '/')); total = arg1/ arg2; return total; } 10+ 20 10 * 20 10 - 30 200 20 = -10 10/200 } 2) Write your codes again in C++, Python by using total as a global variable. Don't return total from the function and the output will be the same.
1) Convert the following Java code by using a function in C++, Python. public class lab9{ public static void main(String []args) { System.out.println(" System.out.println(" System.out.println(" System.out.println(" The output is public static int cale (int arg1, int arg2, char arg3) { int total=0; if (arg3 =='+') } total = arg1 + arg2; if (arg3==¹*¹) total = arg1 * arg2; if (arg3 == '-') total = arglarg2; if (arg3 == '/') 10+ 20 = " + calc(10,20,'+')); 10 * 20 = " + calc( 10, 20, '*')); 10 - 20 = " + calc( 10, 20, '-')); 10/20 = " + calc( 10, 20, '/')); total = arg1/ arg2; return total; } 10+ 20 10 * 20 10 - 30 200 20 = -10 10/200 } 2) Write your codes again in C++, Python by using total as a global variable. Don't return total from the function and the output will be the same.
Chapter2: Using Data
Section: Chapter Questions
Problem 14RQ
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 3 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT