Take 4 digit number input from user, add 8 to the it and then divide it by 3. Now, the modulus of that number is taken with 5 and then multiply the resultant value by 5. Display the final result in java
Answers
Answered by
1
Answer:
class Main {
public static void main (String[] args) {
Scanner sc =new Scanner(System.in);
int n sc.nextInt ();
int p= 8;
int number= ((n+p)/3);
int number2 =(number%5)*5;
System.out.println(number2);
}
}
Explanation:
Run & Pls check !!
correct thn do use it & follow
Answered by
0
Answer:
#include <iostream>
using namespace std;
int main() {
long int n, a;
cout<<"\nEnter a four digit number: ";
cin>>n;
a = (n + 8) / 3;
a = a%5;
a *= 5;
cout<<"\nThe result is "<<a;
return 0;
}
Explanation:
- We start by declaring two variables to store the initial number and the final number.
- Take the four-digit number as input from the user and store it.
- Add 8 to the four-digit number and then divide the sum by 3. Store this result in the second variable.
- Now, find its modulus with 5 using the modulo operator (%).
- Multiply the remainder obtained by 5 and store the result.
- Print the result as output.
#SPJ3
Similar questions