Question

In: Computer Science

using xml, Create a number guessing game You would need an input box and buttons Ask...

using xml, Create a number guessing game

You would need an input box and buttons

Ask the user for a number

Produce a random number from 1-50

Do the comparison

            a. Make sure to provide hints back to the user if the number enter is low or high

                        -this element should be automatically added

            b. Clear the value enter in the text

            c. Give them 3 tries

Whether the user wins or loses, display all the guesses along with the actual number with

congrats or try again message

            -after the message, allow them to play again

Solutions

Expert Solution

<?xml version="1.0" encoding="utf-8"?>

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:app="http://schemas.android.com/apk/res-auto"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    tools:context=".MainActivity">

    <RelativeLayout

        android:layout_width="409dp"

        android:layout_height="729dp"

        android:background="#F3A68E"

        app:layout_constraintBottom_toBottomOf="parent"

        app:layout_constraintEnd_toEndOf="parent"

        app:layout_constraintHorizontal_bias="1.0"

        app:layout_constraintStart_toStartOf="parent"

        app:layout_constraintTop_toTopOf="parent">

        <TextView

            android:id="@+id/textView"

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_alignParentStart="true"

            android:layout_alignParentLeft="true"

            android:layout_alignParentTop="true"

            android:layout_marginStart="77dp"

            android:layout_marginLeft="77dp"

            android:layout_marginTop="47dp"

            android:background="#FF9100"

            android:text="GUESS THE NUMBER"

            android:textSize="30sp" />

        <TextView

            android:id="@+id/textView2"

            android:layout_width="391dp"

            android:layout_height="68dp"

            android:layout_alignParentStart="true"

            android:layout_alignParentLeft="true"

            android:layout_alignParentTop="true"

            android:layout_marginStart="21dp"

            android:layout_marginLeft="21dp"

            android:layout_marginTop="147dp"

            android:text="I am thinking a number between 1 to 100. Can you guess what it is ?"

            android:textSize="24sp"

            app:layout_constraintEnd_toEndOf="parent"

            app:layout_constraintStart_toStartOf="parent" />

        <EditText

            android:id="@+id/editId"

            android:layout_width="348dp"

            android:layout_height="67dp"

            android:layout_alignParentTop="true"

            android:layout_alignParentEnd="true"

            android:layout_alignParentRight="true"

            android:layout_marginTop="271dp"

            android:layout_marginEnd="30dp"

            android:layout_marginRight="30dp"

            android:ems="10"

            android:gravity="center"

            android:hint="ENTER"

            android:inputType="numberDecimal" />

        <Button

            android:id="@+id/button"

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_alignParentEnd="true"

            android:layout_alignParentRight="true"

            android:layout_alignParentBottom="true"

            android:layout_marginEnd="152dp"

            android:layout_marginRight="152dp"

            android:layout_marginBottom="266dp"

            android:onClick="clickFunction"

            android:text="GUESS"

            android:textSize="30sp"

            app:layout_constraintEnd_toEndOf="parent"

            app:layout_constraintStart_toStartOf="parent" />

    </RelativeLayout>

</androidx.constraintlayout.widget.constraingLayout>


Related Solutions

using xsd, Create a number guessing game You would need an input box and buttons Ask...
using xsd, Create a number guessing game You would need an input box and buttons Ask the user for a number Produce a random number from 1-50 Do the comparison ​a. Make sure to provide hints back to the user if the number enter is low or high ​​-this element should be automatically added ​b. Clear the value enter in the text ​c. Give them 3 tries Whether the user wins or loses, display all the guesses along with the...
guessing game in Java. It will have a guess input used for guessing the random number...
guessing game in Java. It will have a guess input used for guessing the random number that is generated from 1 - 100. When the user makes a guess it will tell them if the number is lower or higher than the guess. There is also a choice to give up which then reveals the correct number. The last choice will be new game which resets the random number. Last, the program should keep counts of tries. When the user...
Python: You will modify the given code to create a guessing game that takes user input...
Python: You will modify the given code to create a guessing game that takes user input and allows you to make multiple guesses. There should also be a loop Use the following attached Sample Code as a guide. There are mistakes in the code!!! #Guessing Game import random number=random.randint(1, another number) print("Hello, CIS 101") print("Let's play a guessing Game!called guess my number.") print("The rules are: ") print("I think of a number and you'll have to guess it.") guess = random.randint(1,...
Java guessing game: For this program you will use Linear Search. - Ask the user to...
Java guessing game: For this program you will use Linear Search. - Ask the user to choose between a number from 0 to 2000. - The user will guess how long the linear search will take in nanoseconds, - After the user puts in their answer, show the user the difference between the actual answer and their answer. (Example: The user puts in 5 nanoseconds. The actual time is 11 nanoseconds. The program will show 6 nanoseconds.) There should be...
1. [100] Create a C program for a number guessing game. Here are the requirements: a....
1. [100] Create a C program for a number guessing game. Here are the requirements: a. Your program generates a random number between -100 and 100 and keeps asking the user to guess the number until the user guesses it correctly. Your random number generator should be implemented as a C function which takes min and max values as input parameters and returns a random number between those values including the min and the max. b. If the user guesses...
Part1. Create a number guessing game in Python. Randomly generate a number from 1 to 10....
Part1. Create a number guessing game in Python. Randomly generate a number from 1 to 10. Have the user guess the number. If it is too high, tell the user to guess lower - it it is too low, tell the user to guess higher. Continue until she guesses the correct number. - Part 2. Allow the user to play a new game after they have guessed correctly.   Part 3. Ask for a different name and keep track of how...
in java Create simple number guessing game as follows. First, prompt the user to enter a...
in java Create simple number guessing game as follows. First, prompt the user to enter a min and max value. In your code, declare and assign a variable with a random integer in this range (inclusive). Then, ask the user to guess the number. Input the user's guess. And at the end output "Correct!" if the user's guess was right on spot, or "Sorry, the answer is not corrcet.” The number I was looking for was xxx. Replace xxx with...
Using pseudocode design a number guessing game program. The program should generate a random number and...
Using pseudocode design a number guessing game program. The program should generate a random number and then ask the user to guess the number. Each time the user enters his or her guess, the program should indicate it was too high or too low. The game is over when the user correctly guesses the number. When the game ends, the program should display the number of guesses that the user made.
Project 5-3: Guessing Game Create an application that lets a user guess a number between 1...
Project 5-3: Guessing Game Create an application that lets a user guess a number between 1 and 100. Console Welcome to the Guess the Number Game ++++++++++++++++++++++++++++++++++++ I'm thinking of a number from 1 to 100. Try to guess it. Enter number: 50 You got it in 1 tries. Great work! You are a mathematical wizard. Try again? (y/n): y I'm thinking of a number from 1 to 100. Try to guess it. Enter number: 50 Way too high! Guess...
Part (a) Write a number guessing game using System.Collections.Generic.Dictionary. Generate 10 distinct random numbers in the...
Part (a) Write a number guessing game using System.Collections.Generic.Dictionary. Generate 10 distinct random numbers in the range of 1 to 20. Each random number is associated with a prize money (from 1 to 10000). Use a Dictionary to store the mapping between the random number and the prize money. Ask user for two distinct numbers, a and b, both from 1 to 20; if a and b are not distinct, or out of range, quit the program Lookup the prize...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT