| C++ Data Structure Exercise 2 |
βββββββββββββββββ
Question. Define a function which increments each elements of the array by 2.
AI Programming @freecodecs
Have a Litπ₯ Practice Folks ππ½
βββββββββββββββββ
Question. Define a function which increments each elements of the array by 2.
AI Programming @freecodecs
Have a Litπ₯ Practice Folks ππ½
ββββββββββββββββ
| C++ Data Structure Exercise 2 |
ββββββββββββββββ
Question. Define a function which increments each elements of the array by 2.
(N.B. The code for the above question and answer posted in picture, now on this post in plaintext)
ββββββββββββββββ
#include <iostream>
using namespace std;
void numinc(int x, int *nums)
{
for(int i=0; i<x; i++){
*nums += 2;
cout<<*nums<<"\n";
nums++;
}
}
int main(){
int num[5]={3,4,5,7,11};
numinc (5, num);
return 0;
}
AI Programming @freecodecs
Have a Litπ₯ Practice Folks ππ½
| C++ Data Structure Exercise 2 |
ββββββββββββββββ
Question. Define a function which increments each elements of the array by 2.
(N.B. The code for the above question and answer posted in picture, now on this post in plaintext)
ββββββββββββββββ
#include <iostream>
using namespace std;
void numinc(int x, int *nums)
{
for(int i=0; i<x; i++){
*nums += 2;
cout<<*nums<<"\n";
nums++;
}
}
int main(){
int num[5]={3,4,5,7,11};
numinc (5, num);
return 0;
}
AI Programming @freecodecs
Have a Litπ₯ Practice Folks ππ½
ββββββββββββββββ
| JAVA : Exercise 1. |
ββββββββββββββββ
Question. Wire a Java program which performs the following problems/questions.
P1. Using if else statement make a salary tax rate (payroll system) which accepts salary from the user and replies itβs tax and net pay.
P2. Using conditional statement compare two numbers which replies the first number is greater-than/less-than the second and vice versa.
N.B. Use this Payroll System Rules
1. Below 600 birr (non-taxable)
2. Between 601 & 1,650 (10% tax & 60 birr deduction)
3. Between 1,651 & 3,200 (15% tax & 142.50 deduction)
4. Between 3,201 & 5,250 (20% tax & 302.50 deduction)
5. Between 5,251 & 7,800 (25% tax & 565 birr deduction)
6. Between 7,801 & 10,900 (30% tax & 955 birr deduction)
7. Over 10,900 (35% tax & 1500 birr deduction)
βββββββββββββ
AI Programming @freecodecs
Have a Litπ₯ Figuring Out ππ½
| JAVA : Exercise 1. |
ββββββββββββββββ
Question. Wire a Java program which performs the following problems/questions.
P1. Using if else statement make a salary tax rate (payroll system) which accepts salary from the user and replies itβs tax and net pay.
P2. Using conditional statement compare two numbers which replies the first number is greater-than/less-than the second and vice versa.
N.B. Use this Payroll System Rules
1. Below 600 birr (non-taxable)
2. Between 601 & 1,650 (10% tax & 60 birr deduction)
3. Between 1,651 & 3,200 (15% tax & 142.50 deduction)
4. Between 3,201 & 5,250 (20% tax & 302.50 deduction)
5. Between 5,251 & 7,800 (25% tax & 565 birr deduction)
6. Between 7,801 & 10,900 (30% tax & 955 birr deduction)
7. Over 10,900 (35% tax & 1500 birr deduction)
βββββββββββββ
AI Programming @freecodecs
Have a Litπ₯ Figuring Out ππ½
Answers. P1: Salary Payroll & P2: Number Comparing ππ½ππ½
ββββββββββββββββ
AI Programming @freecodecs
Have a Litπ₯ Practice Folks ππ½
ββββββββββββββββ
AI Programming @freecodecs
Have a Litπ₯ Practice Folks ππ½
Payroll.java
1.2 KB
Answer. P1. Salary Payroll - Java File
βββββββββββββββββ
AI Programming @freecodecs
Have a Litπ₯ Practice Folks ππ½
βββββββββββββββββ
AI Programming @freecodecs
Have a Litπ₯ Practice Folks ππ½
Compare Nums.java
472 B
Answer. P2. Number Comparing - Java File
βββββββββββββββββ
AI Programming @freecodecs
Have a Litπ₯ Practice Folks ππ½
βββββββββββββββββ
AI Programming @freecodecs
Have a Litπ₯ Practice Folks ππ½
βββββββββββββββββ
| JAVA : Exercise 2. |
βββββββββββββββββ
Question. Wire a Java program which operates as a calculator using 4 basic operations (ββββοΈ).
(N.B. Use switch method to perform the conditions)
ββββββββββββββββ
AI Programming @freecodecs
Have a Litπ₯ Figuring Out ππ½
| JAVA : Exercise 2. |
βββββββββββββββββ
Question. Wire a Java program which operates as a calculator using 4 basic operations (ββββοΈ).
(N.B. Use switch method to perform the conditions)
ββββββββββββββββ
AI Programming @freecodecs
Have a Litπ₯ Figuring Out ππ½
JAVA : Ex. 2 Answer - Calculator in Plaintext Code
βββββββββββββββββ
(N.B. Save this class by the name Calculatorx.java to compile and run)
import java.util.Scanner;
public class Calculatorx{
public static void main(String args[]){
double result;
Scanner opr_in = new Scanner(System.in);
System.out.println("Enter the fist no. :");
double num1 = opr_in.nextDouble();
System.out.println("Enter the second no. :");
double num2 = opr_in.nextDouble();
System.out.println("Insert Operation + - * /:");
string oper_x = opr_in.nexLine();
switch(oper_x){
case β+β:
result = num1 + num2;
break;
case β-β:
result = num1 - num2;
break;
case β*β:
result = num1 * num2;
break;
case β/β:
result = num1/num2;
break;
default:
System.out.println("the operator is not set correctly!");
break;
}
System.put.println("the result is" + result);
opr_in.close();
}
}
ββββββββββββββββ
AI Programming @freecodecs
Have a Litπ₯ Practice Folks ππ½
βββββββββββββββββ
(N.B. Save this class by the name Calculatorx.java to compile and run)
import java.util.Scanner;
public class Calculatorx{
public static void main(String args[]){
double result;
Scanner opr_in = new Scanner(System.in);
System.out.println("Enter the fist no. :");
double num1 = opr_in.nextDouble();
System.out.println("Enter the second no. :");
double num2 = opr_in.nextDouble();
System.out.println("Insert Operation + - * /:");
string oper_x = opr_in.nexLine();
switch(oper_x){
case β+β:
result = num1 + num2;
break;
case β-β:
result = num1 - num2;
break;
case β*β:
result = num1 * num2;
break;
case β/β:
result = num1/num2;
break;
default:
System.out.println("the operator is not set correctly!");
break;
}
System.put.println("the result is" + result);
opr_in.close();
}
}
ββββββββββββββββ
AI Programming @freecodecs
Have a Litπ₯ Practice Folks ππ½
π1
AI Programming pinned Β«JAVA : Ex. 2 Answer - Calculator in Plaintext Code βββββββββββββββββ (N.B. Save this class by the name Calculatorx.java to compile and run) import java.util.Scanner; public class Calculatorx{ public static void main(String args[]){ double result;β¦Β»
AI Programming
JAVA : Ex. 2 Answer - Calculator in Plaintext Code βββββββββββββββββ (N.B. Save this class by the name Calculatorx.java to compile and run) import java.util.Scanner; public class Calculatorx{ public static void main(String args[]){ double result;β¦
Tip : If it doesnβt work or needs initializing
Just edit line 4 by (double result = 0;)
N.B. The code is without the parenthesis
Just edit line 4 by (double result = 0;)
N.B. The code is without the parenthesis