Computer Science, asked by aliyahholtzclaw, 1 year ago

[This is on Edhesive (coding and programming)]
2.2 Code Practice
Question 1:
Ask the user to input an integer. Print out the next three consecutive numbers.

Question 2:
Write a program that accepts three decimal numbers as input and outputs their sum.

Answers

Answered by helpingbuddy40
3
Im doing it in java.

1.
public class numbers
{
psvm(String args[])throwsIOException
{
DataInputStream in=new DataInputStream(System.in);
System.out.println("enter a number");
int a=Integer.parseInt(in.readLine());
System.out.println("The next consecutive numbers are:");
System.out.println((a+1));
System.out.println((a+2));
System.out.println((a+3));
}

2.
just ask the user to enter three decimals and accept them using three doubles a,b and c.
Then add them and print.
:-)

aliyahholtzclaw: It won't work with Java, has to be through Edhesive's coding :(
helpingbuddy40: idk whata edhesive coding,sorry:(
davidberube: Edhesive Uses Python for it's intro to CS course
Answered by isaiahjohnson7878
65

This is the answer:

Question 1: a = float(input("Enter an integer: "))


print (a + 1)

print (a + 2)

print (a + 3)


Question 2:

a = float(input("Enter a decimal: "))

b = float(input("Enter another decimal: "))

c = float(input("Enter a third decimal: "))

print ("sum: " + str(a + b + c))

Similar questions