Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I just need solution for part #3. Thank you. Examine the Java code provided in the following three tasks. Create a separate Console application (or

I just need solution for part #3. Thank you.

image text in transcribed

image text in transcribed

image text in transcribed

Examine the Java code provided in the following three tasks. Create a separate Console application (or Class Library if specified) for each task and re-write Java code into C# following the logic of the examples. Use as many C# specific features as possible. Submit your work to BB, so all your source code and output can be seen in full. You can do your work either in Visual studio or in Visual studio code (your choice) 1. Translate to C# the following Java code: 4- 3 public class Reportsum { public static void main(String args[]) { //assume we have 2 numbers a and b, a = 2, b = 5 int a = 2; int b = 5; System.out.println("Provided Integers: ta + " and " + b + ", the total is " + (a+b)); //assume we have 2 numbers a and b, a = 4, b = 4 a = 4; b = 4; System.out.println("Provided Integers: " + a + " and " + b + ", the total is " + (a+b)); //assume we have 2 numbers a and b, a = 1000, b = 2000 a = 1000; b = 2000; System.out.println("Provided Integers: " + a + " and " + b + ", the total is " + (a+b)); 16 17 18 10 19 20 21 22 23 24 25} //assume we have 2 numbers a and b, a = 100, b = 101 a = 100; b = 101; System.out.println("Provided Integers: " + a + and " + b + ", the total is " + (a+b)); } Provide your source code and output in the form ReportSum [Java Application] C:\Program Files\Javaljdk Provided Integers: 2 and 5, the total is 7 Provided Integers: 4 and 4, the total is 8 Provided Integers: 1000 and 2000, the total is 3000 Provided Integers: 100 and 101, the total is 201 2. Translate to C# the following Java code: 1 package lessons; 2 3 import java.util.Scanner; 4 5 public class ReportSum3 { 60 public static void main(String args[]) { 7 Scanner sc = new Scanner(System.in); 8 9 1/ Prompt the user to enter the first integer 10 System.out.println("Enter the value for 'a' and press Enter: "); 11 int a = sc.nextInt(); 12 1/ Prompt the user to enter the second integer 13 System.out.println("Enter the value for 'b' and press Enter: "); 14 int b = sc.nextInt(); 15 16 1/Close the Scanner. It's a good practice to release the resource that was acquired 17 sc.close(); 18 19 1/ Display the result 20 System.out.printf("Provided Integers: %4d and %4d, the total is %d ", a, b, (a + b)); 21 } 22 } Provide your source code and output in the form ReportSum3 (Java Application) C:\Program Files\Java\jdk Enter the value for 'a' and press Enter: 2 Enter the value for 'b' and press Enter: 5 Provided Integers: 2 and 5, the total is 7 ReportSum [Java Application] C:\Program Files\Javaljdk Provided Integers: 2 and 5, the total is 7 Provided Integers: 4 and 4, the total is 8 Provided Integers: 1000 and 2000, the total is 3000 Provided Integers: 100 and 101, the total is 201 3. Translate to C# the following code, move both methods into C# Class library App and call them from Console app. Library code provided 1 package uniti; import java.util.Scanner; public class Library public static void main(String args[]) { Scanner sc = new Scanner(System.in); // Prompt the user to enter the number of integers System.out.println("What number of integers you will provide: "); int num = sc.nextInt(); // Prompt the user to enter the first integer System.out.println("Enter the value for 'a' and press Enter: "); int a = sc.nextInt(); // Prompt the user to enter the second integer System.out.println("Enter the value for 'b' and press Enter: "); int b - sc.nextInt(); if (num == 3) { // Prompt the user to enter the third integer System.out.println("Enter the value for 'c' and press Enter: "); int c = sc.nextInt(); // Display the result System.out.printf("Provided Integers: %4d and %4d and %4d, the total is %d ", a, b, c, sum(a, b, c)); else { 11 Display the result System.out.printf("Provided Integers: %4d and %4d, the total is %d ", a, b, sum(a, b)); } public static int sum(int num], int num2){//2 parameters return num1 + num2; 51 31 320 33 24 34 350 36 37 38 } public static int sum(int numi, int num2, int num3){/73 parameters return numl + num2 + num3; } Submission: Submit both your source code and the output (both fully visible)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

XML Data Management Native XML And XML Enabled Database Systems

Authors: Akmal Chaudhri, Awais Rashid, Roberto Zicari, John Fuller

1st Edition

0201844524, 978-0201844528

More Books

Students also viewed these Databases questions

Question

2. Define communication.

Answered: 1 week ago

Question

What is the growth rate of GDP per capita?

Answered: 1 week ago